darkroomengineering / lenis

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

Smooth nested scroll #259

Closed Ricard-Garcia closed 7 months ago

Ricard-Garcia commented 7 months ago

Describe the bug Smooth scroll lost when scroll is nested.

To Reproduce I'm using ReactLenis component with root in a project and using stop() to lock the scroll when opening a modal. The problem is that, sometimes modals have scroll overflow and using these data attributes makes the content scrollable again but without the smooth scroll.

Do I need to stop() the root ReactLenis component and use a different instance inside the modal or is Lenis not supporting nested scrolls with smooth behaviour?

Thanks, Ricard.

clementroche commented 7 months ago

You need to call new Lenis() on every element you need to be smooth scrolled

Ricard-Garcia commented 7 months ago

Is there a documentation for this? Could it be possible to instantiate Lenis using <ReactLenis> instead of a new instance using new Lenis().

Thanks beforehand, @clementroche.

clementroche commented 7 months ago

just use where you need it to be smoothed, just remove the "root" option

arzafran commented 7 months ago

@Ricard-Garcia, please if the issue is ReactLenis related, use the issues board there, since it could be useful for other users too!

after a quick check I've found someone else already asked that question, and got an answer and examples, here's the link to that issue

Ricard-Garcia commented 7 months ago

That's true, thanks for pointing out the previous issue under the same topic @arzafran !