about summary refs log tree commit diff stats
path: root/lib/epub.js/src
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-03-20 18:28:24 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-03-20 18:28:24 +0300
commit452aa329829ec2cf7b1630045dc66d3eb4dd02bb (patch)
treebfc00653a6235d0aa09febd92295c3bcbb811b87 /lib/epub.js/src
parente974f5ef6dbcdb70fd52b7a208e99cad72252044 (diff)
downloadthe-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')
-rw-r--r--lib/epub.js/src/managers/default/index.js18
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) {