mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-01 13:59:55 +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
|
||||
setTimeout(this.updateScrollPositionFromBoundTiddler.bind(this),50);
|
||||
// Save scroll position on DOM scroll event
|
||||
var timeout;
|
||||
this.outerDomNode.addEventListener("scroll",function(event) {
|
||||
if(timeout) {
|
||||
window.cancelAnimationFrame(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
timeout = window.requestAnimationFrame(function() {
|
||||
var existingTiddler = self.wiki.getTiddler(self.scrollableBind),
|
||||
newTiddlerFields = {
|
||||
title: self.scrollableBind,
|
||||
@ -187,6 +193,7 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) {
|
||||
self.wiki.addTiddler(new $tw.Tiddler(existingTiddler,newTiddlerFields));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user