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

Control box size adjustment issues with 'clipable' during different modes

HZZformGD opened this issue · comments

Environments

  • Framework name: React
  • Framework version: 17
  • Moveable Component version: 0.54.1
  • Testable Address(optional): none

Description

Hey, @daybrush! When using 'clipable', can the control box of the target match the size of the clipping area after clipping or exiting the clipping mode, and revert back to its original size during clipping

Providing an example image from canva.cn, as follows
image
image

Although I'm all for this, I believe this a feature request versus an issue.

I needed this too, and I implemented it by simply creating a virtual clipped Div and swapping the target of the Moveable. It's a bit cumbersome, but it works.

I needed this too, and I implemented it by simply creating a virtual clipped Div and swapping the target of the Moveable. It's a bit cumbersome, but it works.

@bskang-v6x Bro, Could you show me some code plz. i want to know how your code work

I know this doesn't help the open source community, but I don't think I can release the code because it's being used for private purposes by a group larger than myself.

A simple solution is to use

  1. set "Image's Wrapper" as the Target for the Moveable, not "Image", and set the
  2. if it's "Clipable", add a ClipPath to the Wrapper, and when you're done clipping, change the Moveable's Target to the DOM with the size, coordinates, etc. that you added the ClipPath to the Wrapper.
  3. At this point, any Actions that are clipped will need to do some additional processing to the x, y, w, and h of the original Element in the Background.
  4. you'll need to define the appropriate Transform Matrix for each one, for example (let me know if there's a better way to do this).

I apologize for not being able to help you right away.