Jump to content
Search Community

wrong direction

trazetJet
Moderator Tag

Go to solution Solved by trazetJet,

Recommended Posts

Posted

I welcome everyone! Tell me, why does animation without scrolltrigger work from left to right, and with it - on the contrary? I need that animation of emerging panels with months always starts from left to right

img.png

See the Pen OJBKajZ by sdghd (@sdghd) on CodePen.

Posted

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
  • Solution
Posted

I will take into account for the future, thank you

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