aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-02-17 12:50:24 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-03-09 17:01:36 +0900
commitb9d41333c170ca43db8e6cd5159f074fde35b43a (patch)
tree63a49dd9a43b36762d8bb813833c044f0240161e /src/content
parent4a2b2e61342001910abd9ca7fd4932e2a9d7ed8a (diff)
Work around for scrollBy() after scrollTo() does not work
Diffstat (limited to 'src/content')
-rw-r--r--src/content/scrolls.js23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/content/scrolls.js b/src/content/scrolls.js
index 1fa88d1..f3124a1 100644
--- a/src/content/scrolls.js
+++ b/src/content/scrolls.js
@@ -62,29 +62,22 @@ class Scroller {
}
scrollTo(x, y) {
- let behavior = this.smooth ? 'smooth' : 'auto';
+ if (!this.smooth) {
+ this.element.scrollTo(x, y);
+ return;
+ }
this.element.scrollTo({
left: x,
top: y,
- behavior: behavior,
+ behavior: 'smooth',
});
- if (!this.smooth) {
- return;
- }
this.prepareReset();
}
scrollBy(x, y) {
- let behavior = this.smooth ? 'smooth' : 'auto';
- this.element.scrollBy({
- left: x,
- top: y,
- behavior: behavior,
- });
- if (!this.smooth) {
- return;
- }
- this.prepareReset();
+ let left = this.element.scrollLeft + x;
+ let top = this.element.scrollTop + y;
+ this.scrollTo(left, top);
}
prepareReset() {