ionicPopover's position keeps on shifting

I edited ionicPopover in the ionic.bundle.js, because I needed my ionicPopover to have dynamic height and would appear on left or right depended on its position. Somehow it worked as I wanted for awhile, but started to shift positions between two opposite buttons I tested on.

I wonder if there something overwrites it? also if there is other way to customise ionicpopover’s position without having to change on ionic.bundle.js?

thanks in advance