briancray / tooltipsy

Introducing a jQuery tooltip plugin for control-obsessed designers.
http://tooltipsy.com
MIT License
325 stars 97 forks source link

Tooltipping an element in a scrolled div #6

Closed Mantic closed 13 years ago

Mantic commented 13 years ago

I've noticed that the tooltips don't display accurately when the element being tipped is inside of a long div that is being scrolled. The tooltip appears as of the div were not "scrolled" at all, even if the element is scrolled away from its original location.

How would I apply the offset of the element's scrolled position to the tooltip's location?

Mantic commented 13 years ago

Here's a fix!

            do {
                ol += el.offsetLeft  - el.scrollLeft;
                ot += el.offsetTop - el.scrollTop;
            } while (el = el.offsetParent);

just add the -el.scrollTop (or Left) and it properly places itself again. I've tested the Top attribute, not the Left one.

briancray commented 13 years ago

Have you tested this outside of a scrollable element?

Mantic commented 13 years ago

Yes, from my limited testing it works on an element that isn't scrollable. According to jQuery docs, scrollLeft and scrollTop default to 0 on any non-scrolled element. That accommodates for non-scrollable elements.

briancray commented 13 years ago

I'll do some testing and merge it if I find it working. Thanks so much! I'll let you know

briancray commented 13 years ago

Added your fix with some changes. Thanks for your help!

billkeller commented 12 years ago

I still experience this bug, Unless I change it to use jQuery's .offset():

$.tooltipsy.prototype.offset = function (el) {
    return $(el).offset();
}