Jump to content
Search Community

migration to gsap3 -> _gsTransform

jbonlinea test
Moderator Tag

Recommended Posts

hi there

 

I could read in the documentation on how to migrathe that _gsTransform is depreciated in gsap3, ok. It further suggest to edit our old code like such

// old
element._gsTransform.x

// new
gsap.getProperty(element, "x")

That's sounds doable, but in some case the code not use this syntax, for instance in some pen referenced by experienced user in this post where the property is not defined, node being an object of the DOM see below :

 

transform: node._gsTransform,  
x: node.offsetLeft,
y: node.offsetTop,
node

 

How are we suppose to migrate this ?

 

I did several try without success

 

Thank's

 

Link to comment
Share on other sites

2 hours ago, jbonlinea said:

transform: node._gsTransform,  
x: node.offsetLeft,
y: node.offsetTop,
node

 

How are we suppose to migrate this ?

Code that has transform.someProperty you'd do gsap.getProperty(node, someProperty) instead. Is there a specific issue that you're running into? If so, a minimal demo would be helpful in us helping you.

Link to comment
Share on other sites

Hi

 

the answes is yes and no ;)

 

No, I don't, basically since i don't mind this pen anymore since I go with the other one, much simplier and at least as efficient.

 

Yes, because many pens still use the older syntax, and I stil havent figures out how to change this specific peice of code into the new one, so the issue will probably rise again soon or later !

transform: node._gsTransform,  
x: node.offsetLeft,
y: node.offsetTop,
node
Link to comment
Share on other sites

yes I've seen, and and I've also read the doc, really, really seriously, but I still don't get what to change to migrate this piece of code

But we may forget it for now, and I may come back with an other pen that need migration if I bump into issue again

 

transform: node._gsTransform,  
x: node.offsetLeft,
y: node.offsetTop,
node
Link to comment
Share on other sites

7 minutes ago, jbonlinea said:

I still don't get what to change to migrate this piece of code

I told you how to replace the _gsTransform part using node as a reference. That's all you need. Again, I'm confused as to what we're not providing. Perhaps if you made a full, working bit of code that we could help you convert to GSAP 3 that'd make things easier for you to understand.

Link to comment
Share on other sites

A little background that might help the pieces fall into place...

 

In the OLD GSAP (v2 and earlier), a _gsTransform object was added to any elements that had transforms animated/set via GSAP so that it could store the component pieces of the transform independently, like "x", "y", "scaleX", "scaleY", "rotation", etc. In other words, it was an object like: 

element._gsTransform = {
  x: 0,
  y: 0,
  scaleX: 1,
  scaleY: 1,
  rotation: 0,
  skewX: 0,
  ...
};

At runtime, GSAP would pull from those values to combine them into a matrix() or matrix3d(). 

 

BUT that model didn't allow for units, so you could never do something like animate to "20em" or "15vw". In GSAP 3, we moved to a very different model that allows for units and we wanted to streamline things to allow people to "get" values anytime...that's where gsap.getProperty() comes in. 

 

So if you have code that depends on accessing a _gsTransform object directly, that should be rewritten to just get whatever values you need directly via gsap.getProperty(). It'll even do unit conversion for you!

 

Like Zach said...

// the old way
let x = element._gsTransform.x;

// the new way
let x = gsap.getProperty(element, "x");

Does that clear things up? 

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