mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-29 12:59:56 +00:00
Debounce scrollable widget scroll handler
This commit is contained in:
parent
6b47cbed32
commit
c61c34e9df
@ -176,7 +176,13 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
// After a delay for rendering, scroll to the bound position
|
// After a delay for rendering, scroll to the bound position
|
||||||
setTimeout(this.updateScrollPositionFromBoundTiddler.bind(this),50);
|
setTimeout(this.updateScrollPositionFromBoundTiddler.bind(this),50);
|
||||||
// Save scroll position on DOM scroll event
|
// Save scroll position on DOM scroll event
|
||||||
|
var timeout;
|
||||||
this.outerDomNode.addEventListener("scroll",function(event) {
|
this.outerDomNode.addEventListener("scroll",function(event) {
|
||||||
|
if(timeout) {
|
||||||
|
window.cancelAnimationFrame(timeout);
|
||||||
|
timeout = null;
|
||||||
|
}
|
||||||
|
timeout = window.requestAnimationFrame(function() {
|
||||||
var existingTiddler = self.wiki.getTiddler(self.scrollableBind),
|
var existingTiddler = self.wiki.getTiddler(self.scrollableBind),
|
||||||
newTiddlerFields = {
|
newTiddlerFields = {
|
||||||
title: self.scrollableBind,
|
title: self.scrollableBind,
|
||||||
@ -187,6 +193,7 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
self.wiki.addTiddler(new $tw.Tiddler(existingTiddler,newTiddlerFields));
|
self.wiki.addTiddler(new $tw.Tiddler(existingTiddler,newTiddlerFields));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user