feat: natively handle drag and drop from outside #707
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, this PR implements drag & drop from outside, directly in the library.
While I was trying to experiment such feature, I noticed that the related example contained a lot of custom code to make it work. It's not very easy, and not persistent since it relies on internal interfaces (
$refs
, internal/private methods).So I modestly propose this feature:
is-droppable
says whether the grid can accept drag from outside (i.e native draggable elements)before-drop-over
is a callback function used to eventually abort dragover events, or dynamically adapt the size of dragging itemsdrop
is emitted when dropping an elementAbout the implementation, in order to handle the drag events in the
GridLayout
component, I movedcalcXY
andcalcGridColWidth
methods in acalculateUtils
file in order to expose them (I was inspired by the React Grid Layout library for namings). This allows to not rely onGridItem
internal methods.I also moved the placeholder update, may fix #544.