Jump to content
Search Community

Split text always ends up a mess - Help needed adding split text animation to motionpath / scrolltrigger timeline!

Shane Sayers

Recommended Posts

Shane Sayers
Posted

Hey guys, I'm a Webflow designer developer who keeps running into issues implementing split type - every time I  add it to my project, it ends up looking a mess for some reason. 🥲

I've attached an image (down below) of the kind of problems I have been getting.

I'll also attach my code - I have tried so many variations now, honestly it's melting my brain!

Here is the the timeline I want to add the text animation to - I want the text to pop up line by line when the star begins to spin (which you can see in the timeline below). It should be triggered at the same point. (pictured is #star-1)
 

let tl3 = gsap.timeline({
  scrollTrigger: {
    trigger: '#services',
    start: 'top 20%', // trigger when #about comes 30% into view
    end: 'bottom 85%', // set the end point to be 100% of the trigger's height
    scrub: true, // enable scrubbing
    markers: true,
    toggleActions: 'play none none reset', // play the animation when triggered
   
		onUpdate: (self) => {
      if (self.progress >= 0.12 && !self.spun) {
        gsap.to('#star-1', {
          rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
              });
            self.spun = true;
          } else if (self.progress < 0.12 && self.spun) {
            self.spun = false; // Reset the flag when progress goes below 12%
          }

   // Spin #star-2 at 50% progress
      if (self.progress >= 0.27 && !self.spun2) {
        gsap.to('#star-2', {
          rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
        });
        self.spun2 = true; // 
      } else if (self.progress < 0.27 && self.spun2) {
        self.spun2 = false; // Reset the flag when progress goes below 50%
      }

  // Spin #star-3 at 70% progress
      if (self.progress >= 0.53 && !self.spun3) {
        gsap.to('#star-3', {
         rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
        });
        self.spun3 = true; // 
      } else if (self.progress < 0.53 && self.spun3) {
        self.spun3 = false; // Reset the flag when progress goes below 70%
       }
		}
	}
});


tl3.to('.animation-object3', {
  motionPath: {
    path: '#path3',
    align: '#path3',
    alignOrigin: [0.5, 0.8],
    autoRotate: true,
    ease: 'easeInCirc',
    delay: 0,
  },
});


// Add an event listener to the window resize event
window.addEventListener('resize', function() {
  // Invalidate the motion path data for each timeline
  tl1.invalidate();
  tl2.invalidate();
  tl3.invalidate();
  ScrollTrigger.refresh();
});


Here is an example of the kind of staggered text animation I want to add:


let typeSplit = new SplitType('[animate]', {
  types: 'lines, words, chars',
  tagName: 'span'
})

gsap.from('[animate] .line', {
  y: '100%',
  opacity: 0,
  duration: 0.5,
  ease: 'power1.out',
  stagger: 0.1,
  
})
 

Thank you for any help or guidance! 😊

image.thumb.png.79e4a9b2c42b6e51fa66b4eedc0ec6bf.png

 

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 the gsap-trial NPM package for using any of the bonus plugins: 

 

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 @Shane Sayers welcome to the forum!

 

Next to that we would love to see a minimal demo, we don't support third party plugin on the forum only GSAP plugins. Where we do have a split text plugin aptly named SplitText https://gsap.com/docs/v3/Plugins/SplitText/ (which is a plugin benefit for our club members) we can't support the plugin SplitType.

 

Hope it helps and happy tweening! 

Posted

This looks pretty baffling to me! Why are you triggering tweens based on the progress in a callback.

The best way to trigger animations at certain progress points is to create a timeline! That's exactly what timelines are for. I'd love to see a minimal demo - codepen is great for this. ✨

 

let tl3 = gsap.timeline({
  scrollTrigger: {
    trigger: '#services',
    start: 'top 20%', // trigger when #about comes 30% into view
    end: 'bottom 85%', // set the end point to be 100% of the trigger's height
    scrub: true, // enable scrubbing
    markers: true,
    toggleActions: 'play none none reset', // play the animation when triggered
   
		onUpdate: (self) => {
      if (self.progress >= 0.12 && !self.spun) {
        gsap.to('#star-1', {
          rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
              });
            self.spun = true;
          } else if (self.progress < 0.12 && self.spun) {
            self.spun = false; // Reset the flag when progress goes below 12%
          }

   // Spin #star-2 at 50% progress
      if (self.progress >= 0.27 && !self.spun2) {
        gsap.to('#star-2', {
          rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
        });
        self.spun2 = true; // 
      } else if (self.progress < 0.27 && self.spun2) {
        self.spun2 = false; // Reset the flag when progress goes below 50%
      }

  // Spin #star-3 at 70% progress
      if (self.progress >= 0.53 && !self.spun3) {
        gsap.to('#star-3', {
         rotation: "+=720",
          duration: 1,
          ease: 'power4.out' // OutQuart easing
        });
        self.spun3 = true; // 
      } else if (self.progress < 0.53 && self.spun3) {
        self.spun3 = false; // Reset the flag when progress goes below 70%
       }
		}
	}
});

 

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