Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining .request calls on draggable and rotatable results in shifting position #1127

Open
oasjohn opened this issue Aug 2, 2024 · 1 comment

Comments

@oasjohn
Copy link

oasjohn commented Aug 2, 2024

In brief, I'm using JS to reposition and rotate an element incrementally over time, and want the element to rotate about its natural center and reposition relative to its original position. If I do this using the .request calls in this order, the location is shifted relative to the rotated element. (mv is the moveable instance)

newAngle increases over time
newX and newY change over time

mv.request('rotatable', { rotate: newAngle }, true)
mv.request('draggable', { x: newX, y: newY }, true)

If I reverse the operations, it also results in the incorrect position.

mv.request('draggable', { x: newX, y: newY }, true)
mv.request('rotatable', { rotate: newAngle }, true)

I've found that I can effectively separate these operations by resetting rotation to zero, set the new position, then apply the new rotation.

mv.request('rotatable', { rotate: 0 }, true)
mv.request('draggable', { x: newX, y: newY }, true)
mv.request('rotatable', { rotate: newAngle }, true)

However, the position seems to shift after several iterations. This happens even if the newX and newY remain static. Simply calling the draggable request seems to introduce some calculation errors internally over time.

Has anyone seen this or is there a better way to implement these actions?

@oasjohn
Copy link
Author

oasjohn commented Aug 3, 2024

Here is how things progress over time:

Things are OK at first...
rot-ok

After about 50 iterations...things are starting to shift slightly...
rot-bad1

After about 200 iterations...going off the rails...
rot-bad2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant