diff options
Diffstat (limited to 'lib/epub.js/src/managers')
| -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) { |
