diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-03-23 08:21:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-23 08:21:05 +0000 |
commit | 831538e37b0d8bc3b9e78467272b5b1b316b56ac (patch) | |
tree | 2ae70a1f2be6d8cad4285d5eaac1703bf6a02876 /src/content/scrolls.js | |
parent | ddb68535511322174caf5a345eea5731085d8f05 (diff) | |
parent | d0cdb72edbf01d9f79f7d50eff695541a5b45575 (diff) |
Merge pull request #547 from ueokande/qa-0.21
QA 0.21
Diffstat (limited to 'src/content/scrolls.js')
-rw-r--r-- | src/content/scrolls.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/content/scrolls.js b/src/content/scrolls.js index a307aa7..f3124a1 100644 --- a/src/content/scrolls.js +++ b/src/content/scrolls.js @@ -62,31 +62,24 @@ class Scroller { } scrollTo(x, y) { - let behavior = this.smooth ? 'smooth' : 'auto'; - window.scrollTo({ - left: x, - top: y, - behavior: behavior, - }); if (!this.smooth) { + this.element.scrollTo(x, y); return; } - this.prepareReset(); - } - - scrollBy(x, y) { - let behavior = this.smooth ? 'smooth' : 'auto'; - window.scrollBy({ + this.element.scrollTo({ left: x, top: y, - behavior: behavior, + behavior: 'smooth', }); - if (!this.smooth) { - return; - } this.prepareReset(); } + scrollBy(x, y) { + let left = this.element.scrollLeft + x; + let top = this.element.scrollTop + y; + this.scrollTo(left, top); + } + prepareReset() { scrolling = true; if (lastTimeoutId) { |