Skip to content

Commit

Permalink
fix scrollintoview to work with body element
Browse files Browse the repository at this point in the history
  • Loading branch information
John Lindal authored and John Lindal committed Jun 27, 2012
1 parent 0770755 commit 440a5f4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scrollintoview/gallery-scrollintoview-debug.js
Expand Up @@ -53,9 +53,12 @@ Y.Node.prototype.scrollIntoView = function()
{
var hit_top = (ancestor.offsetParent === null);

var a = Y.one(ancestor);
if (ancestor.scrollWidth - a.horizMarginBorderPadding() > ancestor.clientWidth ||
ancestor.scrollHeight - a.vertMarginBorderPadding() > ancestor.clientHeight)
var a = Y.one(ancestor),
b = (Y.Node.getDOMNode(a) === Y.config.doc.body),
w = b ? Y.DOM.winWidth() : ancestor.clientWidth,
h = b ? Y.DOM.winHeight() : ancestor.clientHeight;
if (ancestor.scrollWidth - a.horizMarginBorderPadding() > w ||
ancestor.scrollHeight - a.vertMarginBorderPadding() > h)
{
break;
}
Expand Down Expand Up @@ -130,4 +133,4 @@ Y.Node.prototype.scrollIntoView = function()
};


}, '@VERSION@' ,{requires:['gallery-dimensions']});
}, '@VERSION@' ,{requires:['gallery-dimensions','dom-screen']});

0 comments on commit 440a5f4

Please sign in to comment.