From 8d46c18fc72941137c6e0876253580720e13c8af Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 25 Feb 2015 19:09:53 +0000 Subject: [PATCH] Refine fix for #1526 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix changed the scrolling behaviour such that it only scrolled to the top of a tiddler if the tiddler was entirely offscreen. It wasn’t entirely satisfactory because scrolling was prevented even if only a few pixels of a tiddler are in view. This commit ensures that the scroll does occur if less than 50 pixels of the target is in view --- core/modules/utils/dom/scroller.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/modules/utils/dom/scroller.js b/core/modules/utils/dom/scroller.js index d08207629..1a69b9d91 100644 --- a/core/modules/utils/dom/scroller.js +++ b/core/modules/utils/dom/scroller.js @@ -72,15 +72,14 @@ PageScroller.prototype.scrollIntoView = function(element) { // currentPos/currentSize - position and size of the current scroll viewport // returns: new position of the scroll viewport var getEndPos = function(targetPos,targetSize,currentPos,currentSize) { -console.log("getEndPos",targetPos,targetSize,currentPos,currentSize) // If the target is entirely above/left of the current view, then scroll to its top/left - if((targetPos + targetSize) <= currentPos) { + if((targetPos + targetSize) <= (currentPos + 50)) { return 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)) { return targetPos + targetSize - currentSize; // If the target is out of view below/right, then just scroll to the top/left - } else if(targetPos > (currentPos + currentSize)) { + } else if(targetPos > (currentPos + currentSize - 50)) { return targetPos; // Otherwise, stay where we are } else {