1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 02:19:55 +00:00

Alternative fix for unnecessary startup scrolling

@aelocson here’s an alternative fix for #981, as discussed in
https://github.com/Jermolene/TiddlyWiki5/commit/691e5719a4ff74a04d389bd1
26ba2a69e7651a2a#commitcomment-9848682

It does seem a lot nicer. It avoids the problem you raised, and also
avoids scrolling when a permalink is used.

I suspect that we’d need to make the hard-coded 50 pixels be
configurable.
This commit is contained in:
Jermolene 2015-02-20 20:04:18 +00:00
parent 3746b1b9e8
commit 3df341621d
2 changed files with 4 additions and 2 deletions

View File

@ -133,6 +133,8 @@ function openStartupTiddlers(options) {
target = target.substr(2,target.length - 4);
}
$tw.wiki.addToHistory(target);
} else if(storyList.length > 0) {
$tw.wiki.addToHistory(storyList[0]);
}
}

View File

@ -85,8 +85,8 @@ PageScroller.prototype.scrollIntoView = function(element) {
},
endX = getEndPos(bounds.left,bounds.width,scrollPosition.x,window.innerWidth),
endY = getEndPos(bounds.top,bounds.height,scrollPosition.y,window.innerHeight);
// Only scroll if necessary
if(endX !== scrollPosition.x || endY !== scrollPosition.y) {
// Only scroll if the position has changed, plus a special case that we won't scroll less than 50 pixels from the top of the window
if((endX !== scrollPosition.x || endY !== scrollPosition.y) && (scrollPosition.y !== 0 || endY > 50)) {
var self = this,
drawFrame;
drawFrame = function () {