Jump to content
Search Community

Adding a SplitText timeline to my ScrollTrigger

DeltaFrog test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

Hi All,

 

How do I merge these two codes so the SplitText timeline restarts as well when the ScrollTrigger toggleActions fire?       

 

Currently this ScrollTrigger is working by itself: 

gsap.from("#panel1ID", {
  scrollTrigger: {
    trigger: "#panel1ID",
    toggleActions: "restart pause pause pause"
  }, 
  x: -300, 
  duration: 1,
  ease: "expo.out"
});

 

This is the SplitText timeline which is also working by itself. 


let animation = gsap.timeline({})

function init() {
  
  let split = new SplitText("#panelTitleID1", {type:"chars"})
  animation.from(split.chars, { 

  opacity:0, y:50, ease:"back(4)", stagger:{
    from:"start", //try "center" and "edges"
    each:0.05
  }

})
  
  
}

window.addEventListener("load", init)

 

I tried to merge them like this: 
 

let animation = gsap.timeline({})

function init() {
  
  let split = new SplitText("#panelTitleID1", {type:"chars"})
  animation.from(split.chars, { 

    scrollTrigger: {
    trigger: "#panel1ID",
    toggleActions: "restart pause pause pause"
  }, 

  opacity:0, y:50, ease:"back(4)", stagger:{
    from:"start", //try "center" and "edges"
    each:0.05
  }

})
  
  
}

window.addEventListener("load", init)

 

Can anyone help?  :D 

 

 

 

 

 

Link to comment
Share on other sites

  • Solution

Hey @DeltaFrog :)

 

If I understand your desired outcome, you'd want to add the ScrollTrigger to the timeline rather than individual tweens. There's a nice example on the ScrollTrigger docs page.

https://greensock.com/docs/v3/Plugins/ScrollTrigger

 

A minimal demo would also really help to get you the best answers. ;) 

 

Happy tweening.

:)

 

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