daybrush / moveable

Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!

Home Page:https://daybrush.com/moveable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could resizable support decimal

suanmei opened this issue · comments

Environments

  • Framework name: react-moveable
  • Framework version: 0.56.0

Description

The original size of my element is dynamically calculated. It is most likely not an integer but a decimal. Now after moving it, there are two problems. One is that it will be forcibly set to two integers, causing my aspect ratio to change. Now, the second problem is that after resize, I can no longer go back to the original initial value (decimal).

actual:

console.log(targetRef.current?.getBoundingClientRect(), '====');

output:

bottom: 250
height: 183
left: 844.53125
right: 947.46875
top: 67
width: 102.9375
x: 844.53125
y: 67

In Moveable:

 const onResizeEnd = (e: OnResizeEnd) => {
    console.log(e);
  };

output:

{
   ...
   lastEvent: undefined,
   target: {
      ...
      clientWidth: 103
      clientWidth: 183
   }
}

I just clicked the resize button, the actual resize did not occur. In the output event, I checked the target information, and at this point, the width and height of my element had already been rounded.
So I want to ask why we can't use actual decimals, but we must round them up

I have found the answer.
throttleResize

@suanmei if this is resolved, can you close out your issue?