Share Posted November 10, 2016 I'm using Draggable to give a few elements the option to be dragged around the viewport. I have a function that I'm calling later on that needs the position (x,y) of these dragged items. Is it possible to get the x and y values of those dragged elements? OffsetTop is not working due to the 3d translates. Link to comment Share on other sites More sharing options...
Share Posted November 10, 2016 Have you tried getBoundingClientRect()? That's a method that's available on any DOM element (not related to Draggable). See https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect If you're looking for the actual x/y transform values, you can get those on the Draggable instance (it has "x" and "y" properties), or using element._gsTransform.x and element._gsTransform.y; Does that answer your question? Link to comment Share on other sites More sharing options...
Author Share Posted November 11, 2016 Thanks! The element._gsTransform.x works great. But I cannot seem to get it when working with a ThrowPropsPlugin tween. I want the coordinates when I send an Item to a different position. Animation is all good and smooth. But I want to get all the coordinates during this tween. I only get 1 output at the end when I use the onUpdate function. I've added an Codepen that probably makes it more clear what I want to accomplish: See the Pen qqbvYp?editors=0010 by anon (@anon) on CodePen Link to comment Share on other sites More sharing options...
Share Posted November 11, 2016 I assume this is what you were looking for: http://codepen.io/anon/pen/aBdxMM?editors=0011 Right? 1 Link to comment Share on other sites More sharing options...
Author Share Posted November 14, 2016 Thank you It wasn't clear to me I had to pack it inside an function for it to work as I thought it would. 1 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