fix(utils): streamline scroll animation logic in springScrollTo
- Removed unnecessary requestAnimationFrame handling to simplify the scroll animation process. - Enhanced the stopping condition for animations to ensure smoother transitions during scrolling. These changes improve the efficiency and responsiveness of the scrolling behavior. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
70da1ab94b
commit
4f7158e287
|
|
@ -20,7 +20,7 @@ export const springScrollTo = (
|
|||
isStop = true
|
||||
animation.stop()
|
||||
}
|
||||
let raf: any
|
||||
|
||||
const el = scrollerElement || window
|
||||
const animation = animateValue({
|
||||
keyframes: [scrollTop + 1, y],
|
||||
|
|
@ -34,18 +34,14 @@ export const springScrollTo = (
|
|||
onUpdate(latest) {
|
||||
if (latest <= 0) {
|
||||
animation.stop()
|
||||
return
|
||||
}
|
||||
|
||||
if (raf) {
|
||||
cancelAnimationFrame(raf)
|
||||
if (isStop) {
|
||||
return
|
||||
}
|
||||
raf = requestAnimationFrame(() => {
|
||||
if (isStop) {
|
||||
return
|
||||
}
|
||||
|
||||
el.scrollTo(0, latest)
|
||||
})
|
||||
el.scrollTo(0, latest)
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue