Jump to content
Search Community

Animating SVG line strokes with DrawSVG plugin

bomortensen test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi all,

 

I'm trying to animate an SVG <line> and a <circle> which are both dashed. What I need is the dashes to be shown one-by-one (staggered, I guess :-)) to make the line "drawn".

 

I've tried animating the strokeDasharray like so (where "secondStepDashedLine" is the <line> element) which didn't do anything really:

tlInitial.staggerFrom(secondStepDashedLine, 1, { strokeDasharray: 0 }, 1.5);

Is there any way of doing this? :-)

 

Thanks in advance.

See the Pen XjZkQB by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi bomortensen :)

 

Welcome to the GreenSock forums.

 

The easiest way to animate a dashed line with the drawSVG plugin is by using a mask. I wrote about that technique in our ongoing 'SVG Gotchas' thread here:

 

http://greensock.com/forums/topic/13681-svg-gotchas/?p=57942

 

Hopefully that helps a little bit.

 

Welcome aboard and thanks for being a Club GreenSock member.

 

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