Baret Posted June 4, 2020 Share Posted June 4, 2020 Hi By using TweenMax with the _gsTransform.x instruction I get a precision of at least 6 digits after the comma but by using gsap.getProperty ("# id", "x") I only have 4 digits after the comma . How can I get better accuracy with gsap.getProperty? Jean-Michel Link to comment Share on other sites More sharing options...
GreenSock Posted June 4, 2020 Share Posted June 4, 2020 We intentionally round values to avoid various other problems that can occur, and to improve performance. Can you help me understand WHY you would need more precision? If you really need to, you could use a proxy, sort of like this: var proxy = {factor: 1000, realX: 0, x: function(value) { if (!arguments.length) { return proxy.realX * proxy.factor; } proxy.realX = value / proxy.factor; } }; gsap.to(proxy, {x: 100 * proxy.factor, duration: 10, onUpdate: () => console.log("realX:", proxy.realX)}); It's very unusual that you'd need more than 4 decimal places. Again, I'm curious about what drove your question. 1 Link to comment Share on other sites More sharing options...
Baret Posted June 5, 2020 Author Share Posted June 5, 2020 Hello, Thank you for your response and I am responding to yours. I designed a vernier caliper and I created a vernier drag to help learn how to read the measure (see attached Capture.png). One of the important points in reading is to identify the two graduations which are opposite and which I wish to display in red (see attached Capture4.png). For this I added a snap function whose value corresponds to the offset to have successive alignments. In this case the value of the snap is 1.984375 (see attached Capture5.png). To display the two graduations in red I make the correspondence between the position of the vernier and the graduations opposite. This value is therefore a multiple of 1.984375 . Have I been clear ? Do not hesitate to ask me for more information 3 Link to comment Share on other sites More sharing options...
Baret Posted June 5, 2020 Author Share Posted June 5, 2020 I solved my problem by modifying the drawing and spacing the graduations to have a snap value equal to 2 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