Jump to content


Get/Set properties Greensock way.

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

Hello there,
i'm wondering, is there a way to 'wrap' a DOM element so that i could easily get/set the current tween transforms, TweenLite-wise?
An example to be clear..

console.log(el1.x) //undefined
console.log(gswrapped(el1).x) //yay




//instead of the dreadful

TIA for your attention!


Link to comment
Share on other sites



Every time you tween a CSS transform property, GSAP creates an object called "_gsTransform", that stores all that information and updates it as the animation progresses. This object though acts just as a getter, the engine's native way of setting a value is the basic constructor, so for that you'll have to stick with the set method.


If you want to update a value from the original tween while it's running, you can use the updateTo() method, but for that you have to include TweenMax.js:




You can access the _gsTransform object during an update or at any time after the tween has been created:

// using JS selector
var el1 = document.getElementById("el1");




// using jQuery
var el1 = $("#el1");




I´ve set up a simple codepen:


See the Pen FxHhm by rhernando (@rhernando) on CodePen



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