Jump to content
GreenSock

call007

Not animating x1 and y1 properties for SVG line tag with gsap.quickTo

Go to solution Solved by GreenSock,

Recommended Posts

Hi everyone! I'm trying to animate x1 and y1 line attributes of an svg with gsap.quickTo by mousemove. But it doesn't work at all. Maybe I'm doing something wrong. Or maybe gsap.quickTo doesn't work correctly with these svg attributes. Anyway, please help me to understand how I can solve this problem. Thanks!

See the Pen abqgPYy by call007 (@call007) on CodePen

Link to comment
Share on other sites

Currently, I was able to make what I wanted. But one thing that frustrates me is the duration animation of the mouse ball doesn't match the duration animation of the lines.

See the Pen oNErRLJ by call007 (@call007) on CodePen

Link to comment
Share on other sites

That's because you're creating a bunch of conflicting tweens that are fighting with each other for control on every mousemove event. Just set overwrite: true on your line tweens and that fixes it. 

  • Like 1
Link to comment
Share on other sites

It really works! Thank you, Jack!

Just in case an article about it that I've found.

But I have the last question 😃 Is it possible to animate SVG attributes with gsap.quickTo function?

See the Pen YzemNPy by call007 (@call007) on CodePen

Link to comment
Share on other sites

  • Solution
16 hours ago, call007 said:

But I have the last question 😃 Is it possible to animate SVG attributes with gsap.quickTo function?

No, because .quickTo() is highly optimized to pipe things directly into the low-level PropTweens, skipping initialization, plugin parsing, etc. However, if your goal is to minimize memory (avoid creating a new tween on every mousemove), you could reuse the same tween and just invalidate().restart() it:

See the Pen KKQOGRm?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Does that help?

  • Thanks 1
Link to comment
Share on other sites

That is what I needed. It's perfect! Thank you very much for your help!

  • Like 1
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.
×