Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

swap clone and item

Open olivierdalang opened this issue 6 years ago • 9 comments

Problem:

Current, when using pull: 'clone', at least in the onEnd callback, the element being dragged is e.item while the element that stayed behind e.clone.

This means you're actually dragging the original, while a clone was created and left in place.

To me, this is counter-intuitive, and makes some implementations complicated (e.g. if the original element has some logic that should be kept). I'd suggest inverting this, or at least add another clone mode that has this more correct behaviour

Thanks for the library !!

olivierdalang avatar May 17 '19 12:05 olivierdalang

Why does the API need to be changed? Why does the name of the property matter to the functionality of your app?

Also, I disagree, to me it seems more intuitive to be dragging the original and a clone is being created in it's place.

owen-m1 avatar May 17 '19 12:05 owen-m1

It's not only the name of the property, it's also that the original keeps all events/react bindings/etc, while the other one does not.

In my case, I use SortableJs to create elements from a to a specific location in

. The element in has some logic, while the element that is dropped does not. I have to manually swap the elements after a drop, which is not very elegant.

Of course the point about it being counter-intuitive is personal, but I definitely think both cases should be supported (eg: pull: 'clone' and pull: 'clone-reversed').

olivierdalang avatar May 17 '19 13:05 olivierdalang

I see. I will do this in a later update.

owen-m1 avatar May 17 '19 13:05 owen-m1

Ya, the clone is wrongly implemented because it does not clone the logic of the element.

LucianHij avatar May 22 '19 21:05 LucianHij

Kind of related: #671

OkanEsen avatar Jun 13 '19 19:06 OkanEsen

I see. I will do this in a later update.

@owen-m1 Did you got chance to look into this?

smg99 avatar Dec 11 '19 18:12 smg99

@smg99 Sorry I got a job and haven't had much time to look at Sortable. I can do it but I can't say when but if you want it soon it's best you try to do it yourself and I can answer any questions.

owen-m1 avatar Dec 16 '19 01:12 owen-m1

I'm also having a major issue with this because the bound eventlistener of the original item no longer works! This needs a fix asap imho. A workaround for this is now very ugly and hard to achieve :/

Edit: Actually i found a better way:

  onAdd: function (evt) {
          evt.clone.replaceWith(evt.item)
        } 

masbaehr avatar Mar 31 '20 06:03 masbaehr

我也有一个主要问题,因为原始项目的绑定事件听觉器不再起作用!这需要尽快修复。解决这个问题的方法现在非常丑陋且难以实现:/

编辑:实际上我找到了更好的方法:

  onAdd: function (evt) {
          evt.clone.replaceWith(evt.item)
        } 

You're really great

yaolunmao avatar Feb 14 '22 01:02 yaolunmao