Share Posted May 5 in a scenario where i want to tween a dom element's position, but i would like to also make some caclulations on that current position onUpdate, is there a way that i read that dom element's current position without having to get it off the styles of the element or any of its getters? Link to comment Share on other sites More sharing options...
Share Posted May 6 Hey @danehansen. Can you give a little more context please? What exactly do you mean by "an element's position"? You just want to read the current x/y transform? You can use gsap.getProperty() to read whatever property you want. Link to comment Share on other sites More sharing options...
Author Share Posted May 9 im having a hard time figuring out what is going on when calling gsap.getProperty() by looking at the source code, but i assumed that under the hood that it would be calling element.getBoundingClientRect(), which in theory shouldn't be necessary if there is someplace else to get the value without calculating it off a dom element. am i correct or wrong? Link to comment Share on other sites More sharing options...
Share Posted May 9 59 minutes ago, danehansen said: im having a hard time figuring out what is going on when calling gsap.getProperty() by looking at the source code, but i assumed that under the hood that it would be calling element.getBoundingClientRect(), which in theory shouldn't be necessary if there is someplace else to get the value without calculating it off a dom element. am i correct or wrong? No, that is not correct. That's why I was asking for context - I'm trying to understand the kinds of values you want (and why). If you gsap.getProperty(element, "x"), for example, that will just return the current transform: translateX() (the CSS style). It sounds like maybe you're trying to discern maybe the global coordinate in the viewport (or the page, non-inclusive of scroll position?) of the top left corner of a particular element? You'll significantly increase your chances of getting a good answer here if you provide a minimal demo that clearly illustrates the challenge. (like a CodePen) 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now