Jump to content
Search Community

Smooth Scroll Parallax

Sukru test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hello, I actually want to stop the scroll and parallax effects that are not normal effects on mobile devices. I used a code for this, but smoothscroll still works. can you help me?
 

You can view the project here, thank you very much.

http://clients.super-agency.com/test/dy/

 

I'm using the code below, it turns off the parallax, but the smooth scroll effect still works. I want browser default scrolll on mobile devices.

 

console.clear();
gsap.registerPlugin(ScrollTrigger, ScrollSmoother, SplitText);
 
let smoother = ScrollSmoother.create({
wrapper: "#smoother-wrapper",
content: "#smoother-content",
smooth: 1,
smoothTouch: 0.1,
normalizeScroll: true,
ignoreMobileResize: true,
effects: ScrollTrigger.isTouch === 1 ? false : true,
});

See the Pen bGKpNrJ by sukruemanet (@sukruemanet) on CodePen

Link to comment
Share on other sites

  • Solution

Hey there!

 

smoothTouch adds smooth scroll behaviour on touch devices (like mobile),

normalizeScroll intercepts native scroll behaviour and handles it on the JavaScript thread - this isn't necessary unless you're struggling with specific bugs.

 

If you want normal behaviour on mobile you can remove both of those options.

 

ScrollSmoother.create({
  wrapper: "#smoother-wrapper",
  content: "#smoother-content",
  smooth: 1,
  ignoreMobileResize: true,
  effects: ScrollTrigger.isTouch === 1 ? false : true,
});

 

This option is only setting this up on page load though, I would probably set it up differently to allow for users resizing their screens or plugging in different navigational hardware.

Maybe something like this using GSAP's matchMedia... 

https://cdpn.io/pen/debug/LYrNVra - link for testing

 

See the Pen LYrNVra?editors=0110 by GreenSock (@GreenSock) on CodePen



That's only creating a ScrollSmoother instance on non-touch devices wider than 800px, and removing the smoother added wrapper div on small touch devices too.

 

 

  • Like 3
Link to comment
Share on other sites

2 hours ago, Cassie said:

Hey there!

 

smoothTouch adds smooth scroll behaviour on touch devices (like mobile),

normalizeScroll intercepts native scroll behaviour and handles it on the JavaScript thread - this isn't necessary unless you're struggling with specific bugs.

 

If you want normal behaviour on mobile you can remove both of those options.

 

ScrollSmoother.create({
  wrapper: "#smoother-wrapper",
  content: "#smoother-content",
  smooth: 1,
  ignoreMobileResize: true,
  effects: ScrollTrigger.isTouch === 1 ? false : true,
});

 

This option is only setting this up on page load though, I would probably set it up differently to allow for users resizing their screens or plugging in different navigational hardware.

Maybe something like this using GSAP's matchMedia... 

https://cdpn.io/pen/debug/LYrNVra - link for testing

 

 

 


That's only creating a ScrollSmoother instance on non-touch devices wider than 800px, and removing the smoother added wrapper div on small touch devices too.

 

 

 

 

Thank you very much :)

 

  • Like 1
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.
×
×
  • Create New...