daybrush / moveable

Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!
https://daybrush.com/moveable/
MIT License
10.08k stars 618 forks source link

Snappable element with centered container #888

Closed yuri-dzabaev closed 1 year ago

yuri-dzabaev commented 1 year ago

Environments

Description

Hi @daybrush , thanks a lot for your great work 🙏 I have a centered container with an odd width. And snappable element got half pixel position X (0.5 instead of 0). How can I fix it? (its ok without justifyContent: "center", but I need to center the container) image

daybrush commented 1 year ago

@yuri-dzabaev

moveable's new version is released. Try it again.

yuridzabaev commented 1 year ago

thanks @daybrush ! seems ok for fixed width container, but when the "root" container has a width (or/and height) of 100%, the error seems to be reproduced

I have updated the repro link (when the width of the container is set to 100% then the value of width can be a float, so just for reproduce the issue I set the width to 700.2px manually) https://codesandbox.io/s/nifty-snyder-721im8?file=/src/App.js

daybrush commented 1 year ago

@yuridzabaev

thanks. The delta calculation has been reversed and unnecessary calculations have been removed.

Test with version 0.49.1.

yuridzabaev commented 1 year ago

@daybrush works perfect, thank you! 💪