Giter Site home page Giter Site logo

Comments (5)

Alfred-Skyblue avatar Alfred-Skyblue commented on May 13, 2024

Let me make it clear that your A component uses sortable and B component uses draggable-plus. Do you need to drag the elements in B component to A component?

from vue-draggable-plus.

kwhur avatar kwhur commented on May 13, 2024

Yes, A is using Sortable and B is using draggable-plus.
A represents a folder tree, while B represents a file list.
I am implementing a feature to drag file items from B and drop them into the folder tree of A to move the files.

from vue-draggable-plus.

Alfred-Skyblue avatar Alfred-Skyblue commented on May 13, 2024

In fact, if you are using "draggable-plus," you need to add an element to the two-way bound list when dragging to the target list. It's possible that the element was not added to the list when the drag ended because it wasn't retrieved at that point. This could result in a failed drag operation because when dragging, a bound data is added to the drag target element. However, for security reasons, I've set this bound key as a Symbol type, so it cannot be set from the outside. Would you consider using both components "draggable-plus" and "draggable" to solve this issue?

Related code:

const CLONE_ELEMENT_KEY = Symbol('cloneElement')

/**
* Element dragging started
* @param {DraggableEvent} evt - DraggableEvent
*/
function onStart(evt: DraggableEvent) {
evt.item[CLONE_ELEMENT_KEY] = clone(unref(unref(list)?.[evt.oldIndex!]))
}
/**
* Element is dropped into the list from another list
* @param {DraggableEvent} evt
*/
function onAdd(evt: DraggableEvent) {
const element = evt.item[CLONE_ELEMENT_KEY]
if (isUndefined(element)) return
removeNode(evt.item)
insertElement(unref(list), evt.newDraggableIndex!, element)
}

from vue-draggable-plus.

kwhur avatar kwhur commented on May 13, 2024

Wow, your response is incredibly quick. Thank you so much.
I'll give it a try immediately.

from vue-draggable-plus.

kwhur avatar kwhur commented on May 13, 2024

I've replaced Sortable with Draggable-plus and it resolved the issue.
I'm truly grateful for the excellent library and your rapid support.

from vue-draggable-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.