I have a list of images which could be sorted but items from this list could also be dragged and dropped to a canvas.
Currenty when I take an item from the list and drag it to the canvas the order of the items changes as dragged item passes through the list.
How could I separate this two actions? I.e. when item is dropped outside the list cancel sorting and perform my custom action.
As a friendly word of advice, GitHub issue lists are for reporting issues or bugs with this repository - raising topics that are not issues with the repository make it harder to track issues, and therefore make progress on resolving then.
For support questions - or for questions with your own code or how to do X - you might want to try asking on StackOverflow, where someone will be able to review your code and give you much more in-depth feedback than here.
@awdltd , regardless of @minogin's use-case, I think this would be a useful feature/option to have. Occasionally, when scrolling through a list of sortable items on a touchscreen, I manage to accidentally hit a drag handle, initiating the sorting process - it would be very handy if I could just drop the element outside the list to cancel the process.
@PeterShaggyNoble that's a fair point, and as a feature suggestion it's pertinent to raise here. I was more just providing a useful tip for those specifically seeking support for their code - StackOverflow is always going to be much more helpful for that rather than (as above) asking a question here and possibly not getting any response.
But sure, as a feature suggestion it's certainly not a bad one at all
I'm fine with it @awdltd, but thank you.
@minogin I'm not entirely sure what you are proposing... if you drag an item outside the list, the item shouldn't be moving in the list. It only changes position when you drag it over other list items. If you want to revert it to it's original position after dropping it outside the list, there is the RevertOnSpill plugin.
RevertOnSpill is exactly what I was looking for, thank you!
I didn't know it exists, because the documentation only lists the Swap and MultiDrag -Plugins.
https://sortablejs.github.io/Sortable/#multi-drag
So OnSpill and AutoScroll are currently not documented on that site. Is help wanted with documention? I would create a pull request then, and add them.
Most helpful comment
I'm fine with it @awdltd, but thank you.
@minogin I'm not entirely sure what you are proposing... if you drag an item outside the list, the item shouldn't be moving in the list. It only changes position when you drag it over other list items. If you want to revert it to it's original position after dropping it outside the list, there is the RevertOnSpill plugin.