How to stop scroll on modal pop-up & keep smooth scroll active? #292
-
👋 Any help would be greatly appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 15 replies
-
You shouldn't use the data attributes for that purpose. There are two methods described here. openModal() {
// Your modal open code
lenis.stop()
}
closeModal() {
// Your modal close code
lenis.start()
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply! Unfortunately the link is broken. I'm using the data-lenis-stop attribute on modal open, and data-lenis-start on modal close, however my modal itself has overflow behaviour, so I'm using data-lenis-prevent to keep scroll active on the modal itself. |
Beta Was this translation helpful? Give feedback.
-
I'm having a similar issue with a drawer. I have ReactLenis activated for the root scroll in my NextJS layout. When I open the drawer, I would like the smooth scroll on the root to stop and smooth scroll on the drawer to be active. As it stands, I am able to stop root scrolling via data-lenis-prevent, but the smooth scroll on the drawer does not work. Is this currently possible ? |
Beta Was this translation helpful? Give feedback.
-
Check |
Beta Was this translation helpful? Give feedback.
-
@kipedia please share a reproduction link |
Beta Was this translation helpful? Give feedback.
-
Any other solutions? I got many dialogs, popups, alerts, etc. in my app, it seems not quite right if I need to use I'm using Radix as well as Shadcn, after dig into the code base of one, I see that radix uses import { RemoveScroll } from "react-remove-scroll";
...
const ScrollLockWrapper = disableOutsideScroll ? RemoveScroll : React.Fragment; The problem that Lenis someway override this behavior. How to make Lenis respect that? |
Beta Was this translation helpful? Give feedback.
Check
prevent
option #347