Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
UncleMuscles

How would I convert a SVG animation into GSAP?

Go to solution Solved by elegantseagulls,

Recommended Posts

Hi, GSAP is awesome!

 

I have made an animated 'P' but mainly using SVG <animate> so far I using the SVG to animate strokedash-offset, dash-opacity and fill. I'm aware that I should probably use Draw for the stroke stuff but I can't afford it, I've been out of work for 10 years+ and recently I've decided to become a webdev so I've been designing my portfolio so money is tight.

I was wondering how would I animate these 3 attributes as I have tried using .to() and putting {strokeOpacity: 0} as it is set to 100% initaly but this does not work. How come? I have also had the same problem with strokeDashOffset and Fill. Hoe can I animate these properties with GSap like I have with SVG  below?

 

https://stackblitz.com/edit/paulscv-2qssl8?file=src%2Fbg-components%2FletterP.js

 

Ultimatly my goale is to animates these things with scrollMagic. But for now it would b e nice just to animate them. Is this possible?

 

Thanks :)

Link to comment
Share on other sites

  • Solution

You can animate strokeDashoffset, and all other svg attributes in gsap just as you would any other property.

 

Maybe your target isn't accurate for your animation? also make sure your case is correct strokeDashOffset strokeDashoffset

 

See the Pen GRmqbpY by ryan_labar (@ryan_labar) on CodePen

 

For fine tuning your strokeDashArray animation, check out the DrawSVGPlugin: https://greensock.com/docs/v3/Plugins/DrawSVGPlugin 

 

Also, we don't recommend using ScrollMagic. GSAP has ScrollTrigger: https://greensock.com/docs/v3/Plugins/ScrollTrigger

  • Like 5
Link to comment
Share on other sites

37 minutes ago, elegantseagulls said:

You can animate strokeDashoffset, and all other svg attributes in gsap just as you would any other property.

 

Maybe your target isn't accurate for your animation? also make sure your case is correct strokeDashOffset strokeDashoffset

 

 

 

 

For fine tuning your strokeDashArray animation, check out the DrawSVGPlugin: https://greensock.com/docs/v3/Plugins/DrawSVGPlugin 

 

Also, we don't recommend using ScrollMagic. GSAP has ScrollTrigger: https://greensock.com/docs/v3/Plugins/ScrollTrigger

Ahh i see thanks :) I realised that I had set inital values int he SVG and it didnt like that. So once I removed them it ran fine.

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.

×