GithubHelp home page GithubHelp logo

Comments (2)

tangjian1891 avatar tangjian1891 commented on May 22, 2024

The second question:
file:src/utils/index.ts
/**

  • Inserts a element into the DOM at a given index.
  • @param parentElement
  • @param element
  • @param {number} index
    */
    export function insertNodeAt(
    parentElement: Element,
    element: Element,
    index: number
    ) {
    const refElement =
    index === 0 ? parentElement.firstChild : parentElement.children[index]
    parentElement.insertBefore(element, refElement)
    }

请问:
为什么对于index=0的drag-item要单独获取第一个firstChild。直接使用parentElement.children[index]获取元素不可以吗? 或者使用 parentElement.firstElementChild获取Element不可以吗?

调试发现parentElement.firstChild会获取到textNode或commentNode,这样经过dom操作后,好像导致了vue的diff失效。

from vue-draggable-plus.

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

Hello, thank you for your question. Here is our response:

  1. In the onUpdate function, I performed deletion and insertion operations on the dom element and then used moveArrayElement. The reason for this is that I needed to delete and insert the dom element to trigger the animation effect. Simply moving the array element would not trigger the animation effect when updating the page.
  2. I have already made the necessary modifications to this code in the latest version. Thank you.

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.