Skip to content

Commit 20a789c

Browse files
authored
Enhance auto-scroll functionality in gutkaScript.js (KhalisFoundation#364)
- Introduced touch event handling to manage auto-scroll behavior during user interactions. - Added logic to resume auto-scroll after touch events if it was previously active, improving user experience during scrolling.
1 parent 501c719 commit 20a789c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/ReaderScreen/utils/gutkaScript.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,26 @@ ${listener}.addEventListener(
129129
130130
${listener}.onscroll = scrollFunc;
131131
// Touch events for auto-scroll handling only
132+
let wasAutoScrolling = false;
133+
const resumeAutoScroll = () => {
134+
isManuallyScrolling = false;
135+
// Resume auto-scroll if it was active before touch
136+
if (wasAutoScrolling && autoScrollSpeed !== 0 && autoScrollTimeout == null) {
137+
wasAutoScrolling = false;
138+
setAutoScroll();
139+
}
140+
};
132141
${listener}.addEventListener("touchstart", ()=> {
133142
if (autoScrollSpeed !== 0) {
143+
wasAutoScrolling = true;
134144
clearScrollTimeout();
135145
}
136146
});
137147
${listener}.addEventListener("touchmove", ()=> {
138148
isManuallyScrolling = true;
139149
});
150+
${listener}.addEventListener("touchend", resumeAutoScroll);
151+
${listener}.addEventListener("touchcancel", resumeAutoScroll);
140152
141153
${listener}.addEventListener(
142154
"message",

0 commit comments

Comments
 (0)