Jump to content
Search Community

variables in attributes

gareth test
Moderator Tag

Go to solution Solved by Jonathan,

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,

 

How can I use a variable in the d section of this tween?

TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100 110,40  110,40'},repeat:-1,yoyo:true});

I tried 

TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100' +force+',40'  +force+',40'},repeat:-1,yoyo:true});
Link to comment
Share on other sites

  • Solution

Hello gareth,

 

Looks like you were missing the space between the C100,100 and the first single quote '.

 

d:'M100,300 C100,100SPACE' +force+',40' +force+',40'

// So this
TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100' +force+',40' +force+',40'},repeat:-1,yoyo:true});

// Becomes this:
TweenMax.to("#pole",force,{attr:{d:'M100,300 C100,100 '+force+',40' +force+',40'},repeat:-1,yoyo:true});

:)

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