greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.83k stars 1.72k forks source link

Make "get" methods like CSSPlugin._internals.getTransform() public? #61

Closed fregante closed 10 years ago

fregante commented 10 years ago

Sometimes I wish there was a getter for CSS properties included in GSAP. CSSPlugin has a few methods just for that but they could be made public and perhaps documented.

Why? CSSPlugin works great to parse transforms, for example. Here's what I'm using it for: http://codepen.io/bfred-it/pen/thogH

EDIT: TweenLite._plugins.scrollTo.max() would also be nice

jackdoyle commented 10 years ago

It's much easier to get the transform data like this:

var scaleX = yourElement._gsTransform.scaleX;
var rotation = yourElement._gsTransform.rotation;
...

All of the transform properties are stored there. We haven't made this part of the public API docs just because we weren't 100% sure we wanted to be committed to it long-term. But over time, we have heard many requests for that data (mostly in the forums) and we have told people about the _gsTransform object, so I suppose the cat is out of the bag :)

We're not ready to commit to a full-fledged "get" method because it's a lot more complicated that it may seem, because there are quite a few properties that may not fit nicely into a simplistic API like that and we have to analyze that. But I think the most critical ones for animators are the transform-related values like scaleX, scaleY, rotation, x, y, z, rotationX, rotationY, skewX, etc. and those are all very easily accessible in the _gsTransform object.

Have fun!