summaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-15 17:52:30 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-27 21:41:00 -0400
commit946e577e42db9df43169d8547d4536fe8edd6748 (patch)
tree3ca1d83d1d5bedcd113d71235f507411a49239c2 /ext/mixed/js/display.js
parent9fc69395c5a3c66a9289c73d412f8b92d9bc4b31 (diff)
Implement custom window scroll
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index a3d618e5..e3c44507 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -31,6 +31,8 @@ class Display {
this.dependencies = {};
+ this.windowScroll = new WindowScroll();
+
document.addEventListener('keydown', this.onKeyDown.bind(this));
document.addEventListener('wheel', this.onWheel.bind(this), {passive: false});
}
@@ -53,11 +55,12 @@ class Display {
e.preventDefault();
const link = e.target;
+ this.windowScroll.toY(0);
const context = {
source: {
definitions: this.definitions,
index: this.entryIndexFind(link),
- scroll: $('html,body').scrollTop()
+ scroll: this.windowScroll.y
}
};
@@ -102,11 +105,12 @@ class Display {
textSource.cleanup();
}
+ this.windowScroll.toY(0);
const context = {
source: {
definitions: this.definitions,
index: this.entryIndexFind(clickedElement),
- scroll: $('html,body').scrollTop()
+ scroll: this.windowScroll.y
}
};
@@ -410,7 +414,7 @@ class Display {
$('.current').hide().eq(index).show();
- const container = $('html,body').stop();
+ this.windowScroll.stop();
const entry = $('.entry').eq(index);
let target;
@@ -421,9 +425,9 @@ class Display {
}
if (smooth) {
- container.animate({scrollTop: target}, 200);
+ this.windowScroll.animate(this.windowScroll.x, target, 200);
} else {
- container.scrollTop(target);
+ this.windowScroll.toY(target);
}
this.index = index;