Jump to content
GreenSock

Jloafs

disable ScrollSmoother on specific pages

Go to solution Solved by mvaneijgen,

Recommended Posts

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

  • Solution

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)
	});
}

 

  • Like 3
Link to comment
Share on other sites

Ah, of course. Thanks heaps.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×