Giter VIP home page Giter VIP logo

Comments (11)

phphe avatar phphe commented on June 16, 2024

doc: https://hetree.phphe.com/v2/guide#drop-from-outside

code example:

const externalDataHandler = (e) => {

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

I have read the documentation, I don't need to add a new node, I just need to catch the drop event. According to the documentation, you can return false in @external-drag-over to prevent creating a new node, but then the drop event is not triggered.

The case is as follows: there is a tree of folders in one column and files in another, I need to drag a file onto a folder so that the folder contains this file, but there is no need to add it to the tree of folders.

from he-tree.

phphe avatar phphe commented on June 16, 2024

First , return true in onExternalDragOver. Then use externalDataHandler as onDrop, and return nothing in it.

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

In the current solution there is a placeholder. All of this seems like half measures.

from he-tree.

phphe avatar phphe commented on June 16, 2024

try listen native ondragover, ondrop in your node element and call event.stopPropagation

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

Please check demo. I use stopPropagation. It is precisely because I have not been able to do it the way the HTML Drag and Drop API describes it that I created this issue.

from he-tree.

phphe avatar phphe commented on June 16, 2024
function onDragOver(e) {
  e.preventDefault();
  e.stopPropagation()
  console.log('dragover');
}

function onDrop(e) {
  e.preventDefault();
  e.stopPropagation()
  console.log('drop');
}

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

I should add, I used stopPropagation, but it breaks the behavior when dragging tree nodes. According to the HTML Drag and Drop API, for an element to be a valid target, you only need to call preventDefault on it.

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

https://stackblitz.com/edit/vitejs-vite-h5dofl?file=src%2FApp.vue

Edit

Запись экрана 2024-03-08 в 07 17 32

from he-tree.

phphe avatar phphe commented on June 16, 2024

add a variable, if drag start in tree, set it true, if drag in external, set it false. then call stopPropagation when it is false.

from he-tree.

antonreshetov avatar antonreshetov commented on June 16, 2024

This looks more like a hack than a solution.

from he-tree.

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.