bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
21.89k stars 1.97k forks source link

Idea: Possibility to access initialSibling from outside the dragula function. #698

Open NoCredits opened 1 year ago

NoCredits commented 1 year ago

Hi contributers,

canceling the dropping from within my code doesnt work because my code is waiting for a promise to resolve or reject.

So I added:

item['initialSibling']=_initialSibling to the drop method. Now I can insert the element at it origin:

const promise = new Promise ((resolve, reject) => { doTheDrop (el, target, source, sibling, workflow); }); promise.then( (data) => { //great drop is ok }, (reason) => { // Rejected! source.insertBefore ( el, el.initialSibling == undefined ? null : el.initialSibling ); });

However, I would rather not change dragula.js. Is it possible to access this property some other way?