moveable icon indicating copy to clipboard operation
moveable copied to clipboard

Incorrect aspect ratio when use request

Open jairoblatt opened this issue 3 years ago • 5 comments

Environments

  • Framework name: vanilla
  • Framework version:
  • Moveable Component version:
  • Testable Address(optional): https://codesandbox.io/s/naughty-joliot-vcuf7?file=/src/App.vue

Description

Hi, I found this aspect ratio bug?! when i try to set height or width manually using resizable request.

When i set height or width to 0 and then set value to > 0, automatically the target it's transform to 1:1 aspect.

ezgif com-gif-maker

I tried fix that but I couldn't.

Thanks, This plugin it's awesome

jairoblatt avatar Jan 25 '22 20:01 jairoblatt

@jairoblatt

The moment it becomes 0, I can't help it either.

When it becomes 0, the ratio is broken.

daybrush avatar Mar 12 '22 07:03 daybrush

@jairoblatt

The moment you input the width or height value, the ratio is maintained for a few seconds and you should check if it is 0.

daybrush avatar Mar 12 '22 07:03 daybrush

Yes you're right, I fixed this by saving the initial ratio, when the user changes the value to 0 and then changes to a value > 0 I retrieve the saved ratio to calculate the new height and with, always keeping the initial aspect.

But, I was thinking about this behavior that I implemented outside of moveable, what do you think about implementing this natively?

jairoblatt avatar Mar 12 '22 14:03 jairoblatt

@jairoblatt

That seems difficult. Moveable cannot store the ratio value for the case of 0 x 0.

If you store the ratio value externally, It can be set as setRatio(ratio) in the property of the resizeStart event.

daybrush avatar Mar 12 '22 15:03 daybrush

Right @daybrush , but, the main point here it's, when i define keepRatio:true in the moveable options, i expect the ratio will be respect, even when I set height or/and width to 0. In my point of view the ratio shoud be returned to the original when the value return to greater than 0.

This same behavior is not applied when keepRatio:false, as the user will have full control over the ratio.

If it's still confusing for you, I can create a demo showing the correct behavior (in my view), and then you decide what to do

jairoblatt avatar Mar 12 '22 16:03 jairoblatt