Don't tween if no position change
This commit is contained in:
@@ -175,7 +175,16 @@ export function usePointerHandlers({
|
|||||||
const from = el.scrollLeft
|
const from = el.scrollLeft
|
||||||
const to = getOffsetForIndex(itemWidthsRef.current, targetIndex)
|
const to = getOffsetForIndex(itemWidthsRef.current, targetIndex)
|
||||||
|
|
||||||
stopTween = tween(from, to, SETTLE_DURATION)(
|
if (from === to) {
|
||||||
|
currentIndexRef.current = targetIndex
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
stopTween = tween(
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
SETTLE_DURATION,
|
||||||
|
)(
|
||||||
v => {
|
v => {
|
||||||
scrollTo(v)
|
scrollTo(v)
|
||||||
},
|
},
|
||||||
@@ -200,5 +209,12 @@ export function usePointerHandlers({
|
|||||||
el.style.cursor = ''
|
el.style.cursor = ''
|
||||||
el.style.userSelect = ''
|
el.style.userSelect = ''
|
||||||
}
|
}
|
||||||
}, [flatListRef, itemWidthsRef, currentIndexRef, scrollTo, onSettle, imageCount])
|
}, [
|
||||||
|
flatListRef,
|
||||||
|
itemWidthsRef,
|
||||||
|
currentIndexRef,
|
||||||
|
scrollTo,
|
||||||
|
onSettle,
|
||||||
|
imageCount,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user