Jump to content
Search Community

how to set the start point of scrollTrigger

astrick

Recommended Posts

Posted

I want to do a pinSpacing to false of historyPresent__container but I can't set the correct starting point.

Hi, there are 2 gsap animations of "historyPresent__container" and I just wanna know about the second animation that how to put the start point and the end after calculated everything from the first gsap animation

- if I set the second animation start point to "top", it will go to the top of "historyPresent__container"
- if I set the second animation to +=3000px, it will accumulate from the first animation.
- if I set the second animation to +=0px, it won't accumulate from the first animation and it's equal "top"
- if I set the second animation to +=825px, it will accumulate from the first animation and it will go to the bottom of 'historyPresent__container'", but when I switch to mobile responsive, the starting point is not correct. 

I've been spent 9 hours non-stop for fixing this and still can't fix it. 

if I create a html element down below of "historyPresent__container" as ".test" (css classs), and trigger this class instead and set the start point at top and put end as "+=3000px", the ".test" will create a big 3000px instead. 


 

    gsap.to(".historyPresent__container", {
      scrollTrigger: {
        trigger: ".historyPresent__container",
        start: "top top",
        end: "+=3000px bottom",
        scrub: true,
        pin: true,
      },
    });

    gsap.to(".historyPresent__container", {
      scrollTrigger: {
        trigger: ".historyPresent__container",
        start: "+=3000px bottom",
        end: "+=6000px top",
        scrub: true,
        markers: true,
      },
    });

 

Posted

Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

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

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import GSAP as shown in the Install Helper in our Learning Center : 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Posted

Hi,

 

Definitely don't animate the trigger element especially if you are pinning it:

gsap.to(".historyPresent__container", {
  scrollTrigger: {
    trigger: ".historyPresent__container",
    pin: true,
    //...
  },
});

If you want to match the start point of a ScrollTrigger instance with the end of a previous ScrollTrigger, you can create them in that specific sequence and use the previous method inside the start config option as a function (click the View More details link):

https://gsap.com/docs/v3/Plugins/ScrollTrigger/#start

 

It could be something like this:

gsap.to(element, {
  //..
  scrollTrigger: {
    start: "top top",
    end: "+=3000",
    //...
  },
});

// Right after creating this previous GSAP Tween create the next
gsap.to(element, {
  //..
  scrollTrigger: {
    start: (self) => {
      // Use the end of the previous ScrollTrigger instance as the start of this
      return self.previous().end;
    },
    end: "+=3000",
    //...
  },
});

Hopefully this helps

Happy Tweening!

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