Skip to content

Commit b156f67

Browse files
petrkonecny2Petr Konecny
andauthored
fix: fixed scrolling and timer issue (#12)
Co-authored-by: Petr Konecny <[email protected]>
1 parent 6c04a6a commit b156f67

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/hooks/useAutoScroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class IntervalTimer {
4646
this.onResume?.(this.remaining)
4747
this.paused = false
4848
this.callbackStartTime = new Date().getTime()
49-
setTimeout(() => {
49+
this.timerId = setTimeout(() => {
5050
this.run()
5151
}, this.remaining)
5252
}

src/hooks/useCore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ export const useCore = ({
4545
const activeIndex = customRound(offset, ROUNDING_PRECISION)
4646
// if we are at the last index we need to switch to the second one without animation
4747
// second one because the first one is a clone of the last one
48-
if (activeIndex === paddedChildrenArray.length - 1) {
48+
if (activeIndex >= paddedChildrenArray.length - 1) {
4949
goToPage(1)
5050
}
5151
// if we are at the first index we need to switch to the next to last one without animation
5252
// next to last one because the last one is a clone of the first one
53-
if (activeIndex < 0.01 && activeIndex > -0.01) {
53+
if (activeIndex <= 0.01) {
5454
goToPage(paddedChildrenArray.length - 2, 0)
5555
}
5656
},

0 commit comments

Comments
 (0)