-
I've read a lot about mouse vs. touch vs. pointer events and the contemporary consensus is that pointer events are the way to go (e.g. https://javascript.info/pointer-events). I see the DFlex docs mention mouse events primarily but can it work with pointer events as well? Or is it mouse/touch/pointer-event-agnostic and we should take care about the event management and DFlex only takes care about moving the dragged elements? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Hi @ddenev. This is such a good question. Actually, DFlex feeds on (X/Y) coordination regardless of its source. So characterize it as event-agnostic is a fair characterization. The idea behind it's design is that DFlex will handle the event feed but how it's going to be triggered and when it's up to the application itself which also gives you the freedom to choose the right framework for you instead of doing React/Vue/Soild.. etc plugins. Because there's a store DFlex will transform/reconcile elements according to the dragged movement. So there's no need for extra configuration about how to handle the list of elements to interact with draggable elements. |
Beta Was this translation helpful? Give feedback.
-
@jalal246, thank you very much for the quick reply! DFlex looks very interesting to me since I have been looking for a good framework to use for my own D&D implementation in my app. So far I have built my D&D on top of Interact.js (https://interactjs.io/) but it's EOL. Several more questions:
|
Beta Was this translation helpful? Give feedback.
-
Thanks! Since I would like to avoid the duplicate DOM update - i.e. once by dflex and another time by Vue, I guess I just need to listen to the dflex events and just stop dflex from committing the updated state to the DOM. Do I understand this correctly? |
Beta Was this translation helpful? Give feedback.
-
Aha, so if I understand correctly - everything that happens from "pointerdown" on and during "pointermove" is on dflex, and anything that happens after "pointerup" is on Vue/React/etc., correct? |
Beta Was this translation helpful? Give feedback.
When you change the element position using any current drag-and-drop library, you recreate the entire DOM tree according to the new order. This happens with each new position. What DFlex actually does are two things:
It offers transformation only. If your app doesn't need to reposition the elements, DFlex can apply CSS transformations to the elements without even changing the DOM.
When committing to the DOM is enabled (it's enabled by default), DFlex will check the DOM tree and only update the affected elements. So let's say you have a list with 10 elements and you switch positions between the last two. DFlex will check the element. If the position is in place, it will leave the eleme…