Jump to content
Search Community

Recreate CSS Text Keyframe animation in GSAP with TextSplit Plugin

WebgenStudio test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hello, I'm new to GSAP and wanted a little bit of help with one of my projects. I'm trying to recreate the text animations in this codepen . There are seven different text animations in this codepen. If someone can help me by just recreating only one of the animations as I cant quite grasp how to perfectly time keyframes with staggered animations. 
 

Here is one of my trials for the animation called "revolveScale" in the codepen or also tagged with class "one":

var char='.char';
var duration=5;
var tl=gsap.timeline();
tl.fromTo(char,{x:-150,y:-50,rotation:-180,scale:3,opacity:0},{stagger:{amount:duration*0.6},x:20,y:20,rotation:30,scale:0.3,ease:'none'})
.to(char,{stagger:{amount:duration},opacity:1,ease:'none'},"<")
.to(char,{x:0,y:0,stagger:{amount:duration*0.4},scale:1,rotation:0,ease:'none',delay:duration/char.length},`<+${(duration*0.6)}`);

See the Pen NdwZdW by kh-mamun (@kh-mamun) on CodePen

Link to comment
Share on other sites

  • Solution

Welcome to the forums, @WebgenStudio

 

There are a bunch of ways you could structure this. It just depends on which one you feel is more intuitive for the way your brain works:

 

Use a separate tween for each chunk and use a stagger: 0.05 for them all:

let tl = gsap.timeline();
tl.fromTo(".two span", {
	x: -150,
	y: -50,
	rotation: -180,
	scale: 3
}, {
	x: 20,
	y: 20,
	rotation: 30,
	scale:  0.3,
	duration: 0.24,
	stagger: 0.05
})
.to(".two span", {
	x: 0,
	y: 0,
	scale: 1,
	rotation: 0,
	duration: 0.16,
	stagger: 0.05
}, 0.24) // start after the very first one ends
.to(".two span", {
	opacity: 1,
	duration: 0.4,
	stagger: 0.05
}, 0);

Use a .forEach() to do the staggering: 

let tl = gsap.timeline();
gsap.set(".two span", {
	x: -150,
	y: -50,
	rotation: -180,
	scale: 3
});
gsap.utils.toArray(".two span").forEach((el, i) => {
	tl.to(el, {
		x: 20,
		y: 20,
		rotation: 30,
		scale:  0.3,
		duration: 0.24
	}, i * 0.05);
	tl.to(el, {
		x: 0,
		y: 0,
		scale: 1,
		rotation: 0,
		duration: 0.16
	}, ">");
	tl.to(el, {
		opacity: 1,
		duration: 0.4
	}, i * 0.05);
});

Use keyframes:

let tl = gsap.timeline();
gsap.utils.toArray(".two span").forEach((el, i) => {
	gsap.set(el, {
		x: -150,
		y: -50,
		rotation: -180,
		scale: 3
	});
	tl.to(el, {
		keyframes: [
			{
				x: 20,
				y: 20,
				rotation: 30,
				scale:  0.3,
				duration: 0.24
			}, {
				x: 0,
				y: 0,
				scale: 1,
				rotation: 0,
				duration: 0.16
			}, {
				opacity: 1,
				duration: 0.4,
				delay: -0.4 // to make it start from the beginning
			}
		]
	}, i * 0.05);
});

I hope that helps. 

 

Happy tweening!

  • Like 2
Link to comment
Share on other sites

Wow! You make it look so easy! (Or I’m just dumb.. lol).

Thanks a lot really . I was getting confused on playing the tweens in exactly the right times but your first solution clarified for me that we need to play the second tween right after the first character in the first  tween not the whole tween. I couldn’t be more grateful for the fast response and you actually taking your time to give me different approaches on how to solve it.

 

Again, much appreciated!

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