Jump to content
Search Community

Animate path of SVG symbol?

Robert Wildling

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

Robert Wildling
Posted

Hi, GSAP magicians,

 

I am having trouble with animating a path of a SVG that is referenced as symbols.
The codepen shows a left side, where the SVG is implemented "regularly" in the DOM flow. There, the intended animation works (the rectangle needs to be hovered).

The same thing should happen on the right side, where the SVG is referencing a symbol instead.

 

Does anybody of you guys know what I am doing wrong?

The console shows that the original SVG is "copied" to a shadow-root - can "shadow DOM" be accessed anyway?

 

Much appreciated!

Thanks! 

See the Pen mQyvrX by rowild (@rowild) on CodePen.

Robert Wildling
Posted

@Carl Thank you for clearing that up for me and for pointing me to that great article! Much appreciated!

elegantseagulls
Posted

@Robert Wildling,

 

Good article @Carl! Also, a tip, when animating symbols, or sprites, it is vary useful to use CSS Custom Properties, so that you can animate a specific instance of the symbol or sprite, rather than all of them at once.

 

See the Pen YOWoEa by elegantseagulls (@elegantseagulls) on CodePen.

 

  • Like 6
  • 2 years later...
Posted

@anishjana_ DrawSVG animates SVG, not canvas. With that being said, you can use GSAP to animate anything, so if you had an object that is determining the length of a line in canvas you could animate that object, re-render, and it would act similarly to what DrawSVG does.

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