bitovi / bitovi/jquerypp

drop.cancel() cancels the Drop-Binding forever?

Open
#56 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
155
PR merge metrics
No merged PRs in 30d

Description

I have different kinds of Drag-Drop-Operations in my app. Situation: Lot's of DropInit-Listeners are waiting for a Drag to call the DropInits. (SVG-Diagramming App.)

The drag-Object transports some semantic information, so every DropInit can decide to call the "drop.cancel()" method. Some DropInits will call the cancel method some won't call it. That's fine, because some want to take part in the upcoming DragDrop-Operation and some won't.

Problem: The next time a DragInit is done the DropInits of my previously "canceled" Drops are not informed. So the drop.cancel() canceles the DropHandlers forever (?)

Is this the desired behaviour? I would like to cancel the Drop just for the next upcoming DragDrop.

Cause: When a Drop is cancelled it is removed from the newElems-Array in the Drop.add() method. By this these cancelled Drops are not added to this._elements (which is fine). BUT, when cleaning up after the DragDrop the clean() Method just removes the $.data() from all this._elements. By this: In the next Drag-Operation the addCallbacks() method returns FALSE, because an $.data() element is already connected (origData !== null). By this, the old cancelled Drops will not take part in any upcoming Drags, because they are not added the the newElems-Array :(

Solution: I added a similar array like this._elements to the $.Drop and called it this._cancelledElements. In the add() method if (drop._cancelled === true) I add the current Elem to this array. Further I added the $.data() cleanup code for this new array in the clean() method. Works fine.

I could post the code if this will help?

Cheers!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.