Skip to content

Calling stop does not reset velocity #481

@arnaudbrowet

Description

@arnaudbrowet

For a custom application, i need to stop the scrolling, manually apply a scrollTo then resume normal scrolling.

From my testing, i can see that after restarting / reseting the lenis scroll, the previous scroll "momentum" is reapplied which create an unwanted ghost scrolling.. Any idea how to fix that?

 lenis.stop();

requestAnimationFrame(() => {
triggerSnap(target, align, reset, lastVelocity)
})
triggerSnap = ()=>{
[compute some parameters]

const scrollParams = {
                lock: true,
                force: true,
                duration: 0.2,

                onComplete: () => {
                    snapTriggered = false;
                    snapSection = null;
                    lenis.reset()
                    lenis.start();
                }
            }

lenis.scrollTo(lenisScrollPositionElement, scrollParams)
}

=> after the call to reset and start, the window resume a scroll in the direction and the desired behaviour is a complete stop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions