Skip to content
Browse files

fix scrollintoview to work with body element

  • Loading branch information...
1 parent 0770755 commit 440a5f461285a10f9b89f73dbde3ded6b21f3c46 John Lindal committed Jun 26, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 scrollintoview/gallery-scrollintoview-debug.js
View
11 scrollintoview/gallery-scrollintoview-debug.js
@@ -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;
}
@@ -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.
Something went wrong with that request. Please try again.