From b7465c5eb16c7897d761d5b5c86670dc82a2fa8a Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 2 Apr 2015 15:22:50 +0100 Subject: [PATCH] Missed off 7c9976f1d984f48153cdc432ed9580710f75ac7a --- core/modules/utils/dom/scroller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/modules/utils/dom/scroller.js b/core/modules/utils/dom/scroller.js index cc0a3d271..96ec24e6d 100644 --- a/core/modules/utils/dom/scroller.js +++ b/core/modules/utils/dom/scroller.js @@ -73,11 +73,18 @@ PageScroller.prototype.scrollIntoView = function(element) { // returns: new position of the scroll viewport var getEndPos = function(targetPos,targetSize,currentPos,currentSize) { var newPos = currentPos; + // If the target is above/left of the current view, then scroll to it's top/left + if(targetPos <= currentPos) { newPos = targetPos; // If the target is smaller than the window and the scroll position is too far up, then scroll till the target is at the bottom of the window } else if(targetSize < currentSize && currentPos < (targetPos + targetSize - currentSize)) { newPos = targetPos + targetSize - currentSize; + // If the target is big, then just scroll to the top + } else if(currentPos < targetPos) { newPos = targetPos; + // Otherwise, stay where we are + } else { + newPos = currentPos; } // If we are scrolling within 50 pixels of the top/left then snap to zero if(newPos < 50) {