Jloafs Posted June 27, 2022 Share Posted June 27, 2022 Hi. I'm just playing with the new scrollsmoother and wondered if there's a simple way to disable on certain pages rather than apply globally? I notice it automatically creates ids for a scrollcontainer on pages that don't specify a smooth wrapper. Link to comment Share on other sites More sharing options...
Solution mvaneijgen Posted June 27, 2022 Solution Share Posted June 27, 2022 Just wrap the scrollsmoother code in an if statement that checks if a page has a class, something like `.applyScrollSmootherToThisPage` and add that class to the pages you want scrollsmoother on. That's all you need right? if(document.querySelector('.applyScrollSmootherToThisPage'){ ScrollSmoother.create({ smooth: 1, // how long (in seconds) it takes to "catch up" to the native scroll position effects: true, // looks for data-speed and data-lag attributes on elements smoothTouch: 0.1, // much shorter smoothing time on touch devices (default is NO smoothing on touch devices) }); } 3 Link to comment Share on other sites More sharing options...
Jloafs Posted June 28, 2022 Author Share Posted June 28, 2022 Ah, of course. Thanks heaps. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now