darkroomengineering / lenis

How smooth scroll should be
https://lenis.darkroom.engineering
MIT License
9.13k stars 388 forks source link

May I ask if it is possible to add an event for scrollEnd in the future? #313

Closed hengshanMWC closed 8 months ago

hengshanMWC commented 8 months ago

Describe the bug May I ask if it is possible to add an event for scrollEnd in the future? I am currently using setTimeout to make an inaccurate judgment

image
clementroche commented 8 months ago

When should it be dispatched ? Can you show an example where it's useful ?

You alread have acess to onComplete callback

lenis.scrollTo(target, { onComplete: () => {
  console.log('scrollTo completed')
}})
hengshanMWC commented 8 months ago

When should it be dispatched ? Can you show an example where it's useful ?

You alread have acess to onComplete callback

lenis.scrollTo(target, { onComplete: () => {
  console.log('scrollTo completed')
}})

Background: There is an object that triggers animation when the mouse moves in or scrolls. I hope the scrolling animation has a higher priority than the mouse animation, and to abort the mouse animation during scrolling

clementroche commented 8 months ago

i don't understand your issue, can you provide a reproduction link ?

hengshanMWC commented 6 months ago

i don't understand your issue, can you provide a reproduction link ?

Hello, I solved whether it was scrolling by checking the lenis.velocity