Jump to content
Search Community

Scroll to specific section by clicking on button using scroll trigger

Sandeep Choudhary test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hi @mvaneijgen
is it possible to use this feature with in time line
Eg. i have section where scroll trigger is initiated under the time line and when i push into array iam getting the whole time line. any suggestion will be appreciated.
 

details.forEach((detail, index) => {
  let headline = detail.querySelector("h1");
  let benifitsTrigger1 = gsap.timeline({
    scrollTrigger: {
      trigger: headline,
      start: "top 80%",
      end: "top 50%",
      animation: gsap.to(photos[index], { yPercent: 0 }),
      scrub: true
    }
    allSt.push(benifitsTrigger1 );
  });
});

 

Link to comment
Share on other sites

This seems weird to me, but with each reply please link to the demo you're working in so that we can take a look at the code inaction 

 let benifitsTrigger1 = gsap.timeline({
    scrollTrigger: {
      ...
      animation: gsap.to(photos[index], { yPercent: 0 }), // ScrollTrigger is already in a timelie, so it cant also target another animation 
      ...
    }
    allSt.push(benifitsTrigger1); // This can't be inside the timeline object
  });
});

 

What is the issue you're trying to solve?

Link to comment
Share on other sites

Hi @mvaneijgen

See the Pen jORozBR by SandeepChoudhary (@SandeepChoudhary) on CodePen



Here is demo created for you. iam trying to scroll to nth number of slide for each section but not getting any idea how this can achieve in time line.
if i use time line in animation then getting many number of scroll trigger. hopefully will get some hint or suggestion

Link to comment
Share on other sites

I'm not sure what the question is, this is the same as my previous pen right, just with slightly different code. All the scrollTo plugin is doing is animating/scrolling to a point on the page, so lets say your element starts at 3000px you can feed in the value 3000 or like below get that value dynamically through the variables that are build in to the tools

 

See the Pen WNWByjX?editors=1010 by mvaneijgen (@mvaneijgen) 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...