Samuele Posted August 24, 2021 Share Posted August 24, 2021 Hi everyone, I'm trying to set an Horizontal Scroll for the desktop version and a Vertical scroll for the mobile. In order to do that I use the "matchMedia" property in my JS and is pretty cool, but once you resize the screen the scroll is not working as it should. The scroll behavior in the responsive mode works only if the screen is resized. Any thoughts about that? Thanks. See the Pen dyRyKPp by sml-k (@sml-k) on CodePen Link to comment Share on other sites More sharing options...
Solution nico fonseca Posted August 24, 2021 Solution Share Posted August 24, 2021 Hey @Samuele ! You can use ScrollTrigger.matchMedia() to detect the viewport change. The matchMedia has a return function to run the code when you leave the current viewport. See the Pen b991c7897a354e2e5eb20ea84543aab6 by nicofonseca (@nicofonseca) on CodePen 4 Link to comment Share on other sites More sharing options...
Samuele Posted August 24, 2021 Author Share Posted August 24, 2021 Oh I see. Very appreciate thanks! 2 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