mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-13 09:09:25 +00:00
parent
b13d87fdf2
commit
489bc7a50b
|
@ -68,15 +68,19 @@ PageScroller.prototype.scrollIntoView = function(element) {
|
||||||
height: clientBounds.height
|
height: clientBounds.height
|
||||||
};
|
};
|
||||||
// We'll consider the horizontal and vertical scroll directions separately via this function
|
// We'll consider the horizontal and vertical scroll directions separately via this function
|
||||||
|
// targetPos/targetSize - position and size of the target 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) {
|
var getEndPos = function(targetPos,targetSize,currentPos,currentSize) {
|
||||||
// If the target is above/left of the current view, then scroll to it's top/left
|
console.log("getEndPos",targetPos,targetSize,currentPos,currentSize)
|
||||||
if(targetPos <= currentPos) {
|
// If the target is entirely above/left of the current view, then scroll to its top/left
|
||||||
|
if((targetPos + targetSize) <= currentPos) {
|
||||||
return targetPos;
|
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
|
// 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)) {
|
} else if(targetSize < currentSize && currentPos < (targetPos + targetSize - currentSize)) {
|
||||||
return targetPos + targetSize - currentSize;
|
return targetPos + targetSize - currentSize;
|
||||||
// If the target is big, then just scroll to the top
|
// If the target is out of view below/right, then just scroll to the top/left
|
||||||
} else if(currentPos < targetPos) {
|
} else if(targetPos > (currentPos + currentSize)) {
|
||||||
return targetPos;
|
return targetPos;
|
||||||
// Otherwise, stay where we are
|
// Otherwise, stay where we are
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
title: $:/view
|
title: $:/view
|
||||||
|
|
||||||
stacked
|
classic
|
Loading…
Reference in New Issue
Block a user