Jump to content
Search Community

wrong direction

trazetJet test
Moderator Tag

Go to solution Solved by trazetJet,

Recommended Posts

Hi,

 

The problem here is that you're adding your ScrollTrigger configuration to an animation in a timeline. A timeline basically controls the position of a tween's playhead. ScrollTrigger does the same based on the scroll position. So who has control of that particular tween, the timeline or the ScrollTrigger instance? They're both fighting for controlling the tween which causes this result.

 

In this cases just add the ScrollTrigger configuration to the timeline. This seems to work the way you intend:

gsap.registerPlugin(ScrollTrigger);
const tl = gsap.timeline({
  scrollTrigger: {
        trigger: ".split",
        start: "top 15%",
        end: "bottom bottom",
        scrub: 3.5
      }
});
gsap.utils.toArray(".split rect").forEach((panel) => {
  const axisY = panel.getAttribute("y");
  const string = parseInt(axisY);
  tl.fromTo(
    panel,
    {
      height: 52,
      stagger: {
        each: 0.3
      },
      attr: {
        y: `${string + 208}`
      }
    },
    {
      height: 260,
      stagger: {
        each: 0.3
      },
      attr: {
        y: `${axisY}`
      },
      duration: 0.4,
    }
  );
});

 

Hopefully this helps.

Happy Tweening!

 

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