vue-moveable icon indicating copy to clipboard operation
vue-moveable copied to clipboard

Single moveable control box

Open daybrush opened this issue 4 years ago • 8 comments

It has props of target in moveable. Each time the target changes, the moveable box changes.

But only vue is different.

  • vanilla
moveable.target = document.querySelector("'target');
  • react
<Moveable target={document.querySelector(".target")} />
  • Angular
<ngx-moveable [target]="document.querySelector("'target')"/>
  • vue
<vue-moveable>
<div class="target"></div>
</vue-moveable>

https://github.com/daybrush/moveable/issues/55

daybrush avatar Oct 25 '19 05:10 daybrush

Hey @daybrush Thanks for your issue

I guess it's wise to support both versions, e.g.

<vue-moveable :target="document.querySelector(".target")">
   <div class="target"></div>
</vue-moveable>

and

<!-- single target -->
<vue-moveable>
   <div class="target"></div>
</vue-moveable>

<!-- multiple targets -->
<vue-moveable>
   <div class="target"></div>
   <div class="target"></div>
</vue-moveable>

What do you think?

probil avatar Oct 25 '19 08:10 probil

@probil

is it possible?

<vue-moveable :target="document.querySelector('.target')" />

<div class="target"></div>

daybrush avatar Oct 25 '19 08:10 daybrush

right now - no. But I can implement it

probil avatar Oct 25 '19 09:10 probil

@probil

is it possible?

<vue-moveable :target="document.querySelector('.target')" />

<div class="target"></div>

I don't think it's possible in general. Vue will look for document key on the component instance. So such code will throw an error. I guess I would need to pass a selector, e.g.

<vue-moveable target=".target" />

probil avatar Oct 25 '19 12:10 probil

I am not a vue expert, therefore no pull request from my side, but I have tested locally following: I have added to MOVEABLE_PROPS array the target, as props I added target: [HTMLElement], changed the init call of moveable to target: this.target and removed from the template the slot It seems to work without error in my configuration.

Would be nice, if it works for you as well and you can add the changes.

markusnissl avatar Jan 24 '20 08:01 markusnissl

@markusnissl Thanks for your feedback. Some work regarding that was done in v1.6 I'll try to find some time this weekend to make it work properly

probil avatar Mar 13 '20 08:03 probil

Thanks for your great work on this @probil, But I also find it very useful to add support for groups and also make the API the same as the other libraries. I've had a lot of confusion looking at the examples and just realised that this isn't supported in vue-moveable. It'd be great if we could have support for groups and not having target passed as slots necessarily! I guess, for now, I would fall back to the vanilla implementation since I need the grouping to work. I am looking forward to having this feature.

mamsoudi avatar Apr 05 '20 06:04 mamsoudi

Any updates ?

JonathanTreffler avatar Nov 02 '21 14:11 JonathanTreffler