moveable icon indicating copy to clipboard operation
moveable copied to clipboard

How to deal with multiple 'moveable' in a page

Open iCloudys opened this issue 3 years ago • 4 comments

Environments

  • Framework name:moveable
  • Framework version:2.0.0-beta.4
  • Moveable Component version:
  • Testable Address(optional):

Description

How to deal with multiple 'moveable' in a page, and the 'target' can only be operated in the container

图片

iCloudys avatar Dec 06 '21 05:12 iCloudys

@iCloudys same question, did you resolve this problem?

xinnai avatar Dec 22 '21 07:12 xinnai

@iCloudys @xinnai I am a newbie struggling on this lib, too.
In my view: You can use one single moveable instance actually,
by dynamically set moveableInstance.target = document.querySelector('.ele2'),
you can use only one moveable instance without multiple instances because one user basically can only edit one element at a time.
doc here: https://daybrush.com/moveable/release/latest/doc/Moveable.html#target .

SO the target prop of moveable is not only readable but also changeable. however if you changed the target, for the previous target's transform state, you have to maintain/store it by yourself, to someplace, by a variable or store.

If you a using React version or other frameworks, just change the ${target} dynamically, which is passed to Moveable, like this: <Moveable target={$target} />

lgh06 avatar Jan 03 '22 14:01 lgh06

@iCloudys @xinnai

Specify target as an array or selector string

daybrush avatar Jan 03 '22 17:01 daybrush

https://user-images.githubusercontent.com/13017318/154915469-bef45e5b-8e76-4a9d-82a3-48a372d646f3.mp4

iCloudys avatar Feb 21 '22 08:02 iCloudys