Tooltipping an element in a scrolled div #6

Closed
Mantic opened this Issue Jun 12, 2011 · 6 comments

3 participants

@Mantic

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

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
Owner

Have you tested this outside of a scrollable element?

@Mantic

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
Owner

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

@briancray
Owner

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

@briancray briancray closed this Jul 5, 2011
@billkeller

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

$.tooltipsy.prototype.offset = function (el) {
    return $(el).offset();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment