open-amdocs / webrix

Powerful building blocks for React-based web applications
https://webrix.amdocs.com
Apache License 2.0
431 stars 31 forks source link

Movable - update callback is fired unnecessarily when has snap #35

Closed yairEO closed 3 years ago

yairEO commented 3 years ago

Steps to reproduce:

  1. got to: https://codesandbox.io/s/quizzical-greider-szyr3?file=/Example.jsx
  2. grab (with the mouse) the movable element and move the mouse just a little bit so the element doesn't move
  3. see the update callback is fired many times, even through the component hasn't moved.

https://user-images.githubusercontent.com/845031/117292532-fedae900-ae78-11eb-8cf1-c7e4e372706c.mp4

It's worth internally wrapping the callback with requestAnimationFrame if not already done

ykadosh commented 3 years ago

Thanks Yair, that's a good point. I think we can solve this by maintaining the previous coordinates through shared, and only calling update when the coordinates change.

BTW, This is an issue not just for snap(), I assume contain() suffers from the same issue.

udia76 commented 3 years ago

:tada: This issue has been resolved in version 1.3.0-next.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

udia76 commented 3 years ago

:tada: This issue has been resolved in version 1.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: