Skip to content

Commit e5264f1

Browse files
authoredMar 13, 2025··
fix: prevent stuck left-scroll due to negative value (#56)
Signed-off-by: Andrwe Lord Weber <github@andrwe.org>
1 parent 710ea2b commit e5264f1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎assets/hb/modules/slide/js/index.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@
1313
const step = inner.offsetWidth
1414
let left = 0
1515
if (dir === 'left') {
16-
left = inner.scrollLeft - step
16+
left = Math.max(inner.scrollLeft - step, 0 - inner.scrollLeft)
1717
} else {
1818
left = Math.min(inner.scrollWidth - inner.clientWidth, inner.scrollLeft + step)
1919
}
20-
if (left <= 0) {
21-
scrolling = false
22-
return
23-
}
2420

2521
inner.scroll({
2622
left
2723
})
2824
const checker = setInterval(() => {
29-
if (left === inner.scrollLeft) {
25+
if (left === inner.scrollLeft || inner.scrollLeft === 0) {
3026
scrolling = false
3127
clearInterval(checker)
3228
}

0 commit comments

Comments
 (0)
Please sign in to comment.