Jump to content
Search Community

Animate items in hero section onload and then parallax this items on scroll

sleepmanserg test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

  • Solution

Welcome to the forums @sleepmanserg

 

You're going to need to fix some issues with your demo first. If you console.log out depth and movement, you'll see that they are invalid.

gsap.utils.toArray(".parallax").forEach(layer => {
	const depth = layer.dataset.depth;
	const movement = -(layer.offsetHeight * depth)
  console.log("depth", depth)
  console.log("movement", movement)
	tl.to(layer, {y: movement, ease: "none"}, 0)
});

 

image.png

 

That's because your elements don't have a depth data attribute. Only a speed one.

 

 

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