tlindig / position-calculator

jQuery plugin, to calculate the position of an element relative to another element or event. Tries to find a collision free position within the viewport of a given container.
MIT License
101 stars 13 forks source link

Bad calculation in Safari #4

Closed milanstosic closed 9 years ago

milanstosic commented 9 years ago

Hi, I've implemented your library in one mine project but I've noticed that it doesn't calculate position well in Safari on OsX. In Chrome and Firefox works well but in Safari calculation is not ok. Even your example - http://jsbin.com/sifec/1/edit?html,output - position tooltip differently in Safari and other browsers. Have you noticed this?

Btw, great and useful plugin.

tlindig commented 9 years ago

Hi,

oh, no. I did not know this and will check it soon. Unfortunately I have not Internet for next two weeks. I will see, how I can handle this.

Thanks for the hint.

milanstosic commented 9 years ago

Hi,

I've found the source of my problems - bad 'target' option provided to PositionCalculator. Somehow Chrome and Safari differently handled event object and I passed bad value to PositionCalculator. When I corrected that everything worked ok.

Anyway, thank you for your response!

milanstosic commented 9 years ago

Btw, I saw that you used display: none in your bin example. I had problems using display: none because you can't calculate position of hidden element accurately, so I used visibility: hidden and z-index: -1 which I changed to visibility: visible and z-index: 1000.

tlindig commented 9 years ago

Yes, you are right with display: none, but in my examples it is set to display: block before the PositionCalculator will be called.

// ...
$tooltip.show().css({top:0, left:0}); // show() will set display: block

var calculator = new $.PositionCalculator({
// ...
milanstosic commented 9 years ago

He, I didn't see the whole .show() method before .css(). Sorry.

tlindig commented 9 years ago

So, it seams all things are resolved.