Jump to content
Search Community

How would this be adapted to scroll horizontally.

m_web test
Moderator Tag

Recommended Posts

I have a horizontal scrolling website using this code:

 

gsap.registerPlugin(ScrollTrigger);

		const section = gsap.utils.toArray('.horizontal .section');

		function getWidth() {
			let width = 0;
			section.forEach(el => width += el.offsetWidth);
			return width - window.innerWidth;
		}

		gsap.to(section, {
			x: () => -getWidth(),
			scrollTrigger: {
				trigger: '.horizontal',
				pin: true,
				scrub: true,
			}
		});

The site has image sections, that we want to have a horizontal parallax effect, between text sections. I've tried integrating the codepen into our code but I cant get tit to work horizontally. 

See the Pen QWjjYEw by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

What have you tried already? We love to see what you can come up with, that way we can see your thought process and thus better help you understand the tools!

 

If you're new to GSAP check out this awesome getting started guide https://gsap.com/resources/get-started/


Here is a starter template which loads all the plugins

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

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...