Tooltipping an element in a scrolled div #6

Mantic opened this Issue Jun 12, 2011 · 6 comments

3 participants


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?


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.


Have you tested this outside of a scrollable element?


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.


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


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

@briancray briancray closed this Jul 5, 2011

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