Shopify / draggable

The JavaScript Drag & Drop library your grandparents warned you about.
https://shopify.github.io/draggable
MIT License
17.93k stars 1.09k forks source link

Add `insertBy` option to allow prepending or appending elements #514

Open developius opened 2 years ago

developius commented 2 years ago

This PR implements or fixes

This PR allows the user to specify whether they'd like the dragged element to be prepended or appended to the container. I have a use-case where I need to add the element to the top of a scrollable list of elements, so adding it to the bottom causes it to be below the fold and hence the user can't see it.

Does this PR require the Docs to be updated?

Yes, and I've done so (hope they're appropriate).

Does this PR require new tests?

Yes, I've added a default option and added a test for that to ensure backwards compatibility, but it could do with another test to check it actually works. I wasn't able to quickly find a way of doing that, any pointers would be appreciated.

This branch been tested on... (click all that apply / add new items)

Browsers: