locomotivemtl / locomotive-scroll

🛤 Detection of elements in viewport & smooth scrolling with parallax.
https://locomotivemtl.github.io/locomotive-scroll
MIT License
7.97k stars 1.12k forks source link

v5 - start/stop need to also trigger lenis.start/stop #522

Closed albanyacademy closed 1 year ago

albanyacademy commented 1 year ago

Hello 👋

Describe the bug Using stop, mousewheeling a bunch, and then using start causes the page to jump to where you would have scrolled to had you not hit stop before. Logging window scroll events will also not register any while stopped, but when restarted all of those previously ignored wheel events trigger.

Lenis start/stop methods don't preserve this event history. If these are also triggered in the default start/stop methods, then this behaviour doesn't occur and it behaves as you would expect.

To Reproduce Steps to reproduce the behavior:

  1. use stop()
  2. scroll via mousewheel
  3. use start()

Expected behavior When stopped, there should be no scrolling. When started, scrolling should start from where you are currently, regardless of any attempts to wheel in the meantime.

Example of Lenis start/stop: https://codepen.io/wearingalampshade/pen/JjwgZGp

This is particularly noticeable when using fixed position overlays such as modals, where we would want to stop the body scroll.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): All

Thank you 👊