Jump to content


Deep properties support plugin

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 there,


I'm trying to find a solution to have GSAP support deep properties (typically only one level). The reason for this is my application compiles transitions and modifies properties across a number of packages. I'm often doing something like this:


TweenMax.to(target, 5, { position: { x: 500 } });


Out of the box GSAP doesn't support deep properties so I was wondering if there was a plugin or preferred method to accomplish this. Specifying the property directly using:


TweenMax.to(target.position, 5, { x: 500 });


Will really limit what I'm trying to accomplish. Is this done to mitigate performance issues with deeply nested properties?




Link to comment
Share on other sites

Yes, out of the box, a tween will handle animating multiple properties of a single object.


So doing this: TweenMax.to(target.position, 5, { x: 500, y:500 }); is perfectly fine. 


If your properties are complex objects with their own properties and values, then you can create your own PositionPlugin using the instructions here:




However, its fairly straight-forward to tween a function-based value on the target that will act as a getter/setter for position.x

var message = document.getElementById("message");

var obj1 = {
    position: {x:0, y:0},
    positionX: function(val) {
        if (arguments.length === 0) {
            return this.position.x;
        } else {
            this.position.x = val
//tween the position.x 
TweenLite.to(obj1, 2, {positionX:200, onUpdate:function() {
  message.innerHTML = obj1.position.x


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