GithubHelp home page GithubHelp logo

Comments (6)

jalal246 avatar jalal246 commented on June 17, 2024 1

Hi @ddenev , I published a patched version. I hope it solves the issue. I still expect some bugs though.

from dflex.

ddenev avatar ddenev commented on June 17, 2024 1

Thank you, @jalal246! Will test and let you know

from dflex.

ddenev avatar ddenev commented on June 17, 2024 1

I have several questions:

  1. When migrating an element between containers, many $onDragOver and $onDragLeave events are fired (check the sandbox, drag an element from one container to the other and observer the console). Why so many events for a single drag operation?
    Note: I assume these fire for every child of the receiving container but to me this looks wrong
  2. I need an onDrop or a onDragend event, i.e. how do I receive the results from the drag operation?
    Let me explain: I'm using Vue and my lists are rendered based on my reactive state. So I don't really care for DFlex's commit but rather want to receive the proper information during and at the end of the drag operation so that I can update my Vue state - and Vue will take care of the updating/re-rendering the components. That is why I need to "hook" into the proper events, e.g. onDrop.
    The current mutation listener does not work for me either since it just provides an array of new ids in the container and the HTMLElement object - both are not enough for me to understand:
    • which was the element that was moved
    • which was the initial index of the moved element
    • where (index) was it inserted in the receiving container
    • which is the receiving container
      image

from dflex.

ddenev avatar ddenev commented on June 17, 2024 1

@jalal246, that's very nice, thank you! I will play with this the next couple of day and will let you know :)

from dflex.

jalal246 avatar jalal246 commented on June 17, 2024
  1. You're absolutely right. There was indeed an issue (#745) regarding events firing each time the element was transformed when dragged out of the container. I've addressed this and it's now fixed.

  2. I understand your concern. I'll work on finding a solution for this. It would be helpful to have a drag' event that provides information about the path the drag operation took.

Meanwhile, you can try another event: $onLiftUpSiblings when dragged moving out and elements are up,
and $onMoveDownSiblings when dragged enter the container and move elements down.

https://github.com/dflex-js/dflex/blob/main/packages/dflex-dnd/src/Events/constants.ts#L3-L26

from dflex.

jalal246 avatar jalal246 commented on June 17, 2024

@ddenev, $onDragCommitted will emit

type PayloadDragCommitted = {
  /** Represents the main category of the drag event. */
  category: typeof DRAG_CAT;

  /** Indicates the timestamp when the event occurred. */
  timestamp: number;

  /** Targeted elements */
  element: HTMLElement;

  indexes: {
    /** The initial index of the moved element. */
    initial: number;

    /** The index where it was inserted in the receiving container. */
    inserted: number;
  };

  containers: {
    /** The container from which the element originated. */
    origin: HTMLElement;

    /** The container where the element is now located. */
    target: HTMLElement;
  };
}

from dflex.

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.