1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-06-23 00:44:06 +00:00

Now we've got scrolling for navigation in classic view

This commit is contained in:
Jeremy Ruston 2012-10-26 22:20:06 +01:00
parent 324a87a8a2
commit e97f778af4
2 changed files with 6 additions and 5 deletions

View File

@ -57,7 +57,7 @@ $tw.utils.forceLayout(targetElement);
{transform: "none"} {transform: "none"}
]); ]);
// Scroll the target element into view // Scroll the target element into view
$tw.scroller.scrollIntoView(targetElement); $tw.scroller.scrollIntoView(dstRect);
}; };
ClassicListView.prototype.insert = function(index) { ClassicListView.prototype.insert = function(index) {

View File

@ -31,16 +31,17 @@ Scroller.prototype.cancel = function() {
/* /*
Smoothly scroll an element back into view if needed Smoothly scroll an element back into view if needed
element: element or clientrect object
*/ */
Scroller.prototype.scrollIntoView = function(element) { Scroller.prototype.scrollIntoView = function(element) {
var scrollPosition = $tw.utils.getScrollPosition(), var elementBounds = element instanceof HTMLElement ? $tw.utils.getBoundingPageRect(element) : element,
elementBounds = element.getBoundingClientRect(); scrollPosition = $tw.utils.getScrollPosition();
this.cancel(); this.cancel();
this.startTime = new Date(); this.startTime = new Date();
this.startX = scrollPosition.x; this.startX = scrollPosition.x;
this.startY = scrollPosition.y; this.startY = scrollPosition.y;
this.endX = elementBounds.left + scrollPosition.x; this.endX = elementBounds.left;
this.endY = elementBounds.top + scrollPosition.y; this.endY = elementBounds.top;
if((this.endX < this.startX) || (this.endX > (this.startX + window.innerWidth)) || (this.endY < this.startY) || (this.endY > (this.startY + window.innerHeight))) { if((this.endX < this.startX) || (this.endX > (this.startX + window.innerWidth)) || (this.endY < this.startY) || (this.endY > (this.startY + window.innerHeight))) {
var self = this; var self = this;
this.timerId = window.setInterval(function() { this.timerId = window.setInterval(function() {