From a202ddd3bd9cab13964901c556f940cee2a953a8 Mon Sep 17 00:00:00 2001 From: Kenneth Gjersdal <kenneth.gjersdal@avento.no> Date: Fri, 18 Nov 2016 08:41:32 +0100 Subject: [PATCH] CSS-class to identify zones that are possible to drop on on drag start. --- lib/knockout.dragdrop.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/knockout.dragdrop.js b/lib/knockout.dragdrop.js index 74e10dd..40db504 100644 --- a/lib/knockout.dragdrop.js +++ b/lib/knockout.dragdrop.js @@ -93,6 +93,7 @@ this.dragEnter = args.dragEnter; this.dragOver = args.dragOver; this.dragLeave = args.dragLeave; + this.possibleOnDrag = args.possibleOnDrag; this.active = false; this.inside = false; this.dirty = false; @@ -173,8 +174,13 @@ } DropZone.prototype = Zone.prototype; + DropZone.prototype.removePossibleDrag = function() { + toggleClass(this.element, 'drag-possible', false); + } + DropZone.prototype.updateStyling = function () { if (this.dirty) { + toggleClass(this.element, 'drag-possible', this.possibleOnDrag); toggleClass(this.element, 'drag-over', this.active); toggleClass(this.element, 'drop-rejected', this.inside && !this.active); } @@ -270,6 +276,7 @@ forEach(dropZones[name], function (zone) { zone.updateStyling(); + zone.removePossibleDrag(); }); if (winningDropZone && winningDropZone.drop) { @@ -394,6 +401,7 @@ element: element, data: data, drop: options.drop, + possibleOnDrag: options.possibleOnDrag, dragEnter: options.dragEnter, dragOver: options.dragOver, dragLeave: options.dragLeave