diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-03-20 18:28:24 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-03-20 18:28:24 +0300 |
| commit | 452aa329829ec2cf7b1630045dc66d3eb4dd02bb (patch) | |
| tree | bfc00653a6235d0aa09febd92295c3bcbb811b87 /lib/epub.js/src/managers/default | |
| parent | e974f5ef6dbcdb70fd52b7a208e99cad72252044 (diff) | |
| download | the-epube-experimental-smooth-scroll.tar.gz the-epube-experimental-smooth-scroll.tar.xz | |
experimental wip smooth scroll (doesnt work) experimental-smooth-scroll
Diffstat (limited to 'lib/epub.js/src/managers/default')
| -rw-r--r-- | lib/epub.js/src/managers/default/index.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/epub.js/src/managers/default/index.js b/lib/epub.js/src/managers/default/index.js index 8a71695..f5c13b1 100644 --- a/lib/epub.js/src/managers/default/index.js +++ b/lib/epub.js/src/managers/default/index.js @@ -852,7 +852,23 @@ class DefaultViewManager { return visible; } - scrollBy(x, y, silent) { + smoothScrollTo(x, y) { + this.container.scrollTo({left: this.container.scrollLeft + x, top: 0, behavior: 'smooth'}); + + const failed = setTimeout(() => { + reject(); + }, 2000); + + return new Promise((resolve, reject) => { + this.container.addEventListener('scrollend', (evt) => { + clearTimeout(failed); + + resolve(); + }, { once: true }) + }); + } + + scrollBy(x, y, silent) { let dir = this.settings.direction === "rtl" ? -1 : 1; if (silent) { |
