1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Fix tc-adjust-top-of-scroll (#3475)

* correct scrolling with tc-adjust-top-of-scroll

not multiplying `offset` with t causes jumps at the first animation steps, where the offset value is bigger than `endY - scrollPosition.y`

* correct scroll offset
This commit is contained in:
BurningTreeC 2018-11-06 17:23:46 +01:00 committed by Jeremy Ruston
parent 16eb5e1e32
commit 4d1127ed5b

View File

@ -71,7 +71,7 @@ PageScroller.prototype.scrollIntoView = function(element) {
scrollPosition = $tw.utils.getScrollPosition();
return {
left: clientBounds.left + scrollPosition.x,
top: clientBounds.top + scrollPosition.y,
top: clientBounds.top + scrollPosition.y - offset,
width: clientBounds.width,
height: clientBounds.height
};
@ -104,7 +104,7 @@ PageScroller.prototype.scrollIntoView = function(element) {
bounds = getBounds(),
endX = getEndPos(bounds.left,bounds.width,scrollPosition.x,window.innerWidth),
endY = getEndPos(bounds.top,bounds.height,scrollPosition.y,window.innerHeight);
window.scrollTo(scrollPosition.x + (endX - scrollPosition.x) * t,scrollPosition.y + (endY - scrollPosition.y - offset) * t);
window.scrollTo(scrollPosition.x + (endX - scrollPosition.x) * t,scrollPosition.y + (endY - scrollPosition.y) * t);
if(t < 1) {
self.idRequestFrame = self.requestAnimationFrame.call(window,drawFrame);
}