riktar / jkanban

Vanilla Javascript plugin for manage kanban boards
https://www.riccardotartaglia.it/jkanban/
Apache License 2.0
1.09k stars 299 forks source link

Cancel drag #17

Closed marcosrocha85 closed 5 years ago

marcosrocha85 commented 6 years ago

I'm trying to cancel a drag event in order to prevent moving cards on a automatic board, but when I call jkanban.drake.cancel(true) the dragula raises an exception saying "el is null" on touchy function. Do you have any suggestion to implement a "beforeDrag" event in order to validate if a card can be moved? I'm intended to develop that on jKanban.

marcosrocha85 commented 6 years ago

For those who want do that outside jKanban, you can do jkanban.drake.cancel(true) at dropEl event. For example:


jkanban = new jKanban({
...
dropEl: function(el, target, source, sibling) {
    if (myValidationOfCanDrag) {
        jkanban.drake.cancel(true);
    }
}
...
);
marcosrocha85 commented 6 years ago

@riktar, Noticed that dropEl fires even when the property "dragTo" is set and the card is dropped on a target board that supposely shouldn't accept dragging from source board. Is it possible to get the "dragTo" of target at dropEl element?

marcosrocha85 commented 6 years ago

Very close issue to #22

marcosrocha85 commented 5 years ago

Noticed that dropEl fires even when the property "dragTo" is set and the card is dropped on a target board that supposely shouldn't accept dragging from source board.

Suggestion: Don't fire dropEl when the item is now allowed to receive elements from dragTo property.

riktar commented 5 years ago

fixed in: https://github.com/riktar/jkanban/commit/d7ef0efec048595cd0dba34744028b19e55af19c

adryx92 commented 5 years ago

I'm having the same issue. If I drop an item on a non-allowed target, the dropEl is still fired.

I think I'm going to use a custom drag validation, as @marcosrocha85 suggested.