Skip to content
11 changes: 10 additions & 1 deletion lib/knockout.dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -270,6 +276,7 @@

forEach(dropZones[name], function (zone) {
zone.updateStyling();
zone.removePossibleDrag();
});

if (winningDropZone && winningDropZone.drop) {
Expand Down Expand Up @@ -394,6 +401,7 @@
element: element,
data: data,
drop: options.drop,
possibleOnDrag: options.possibleOnDrag,
dragEnter: options.dragEnter,
dragOver: options.dragOver,
dragLeave: options.dragLeave
Expand Down Expand Up @@ -476,12 +484,13 @@

function createCloneProxyElement() {
var dragProxy = element.cloneNode(true);
element.parentNode.appendChild(dragProxy);
var style = window.getComputedStyle(element, null);
dragProxy.style.height = style.getPropertyValue('height');
dragProxy.style.width = style.getPropertyValue('width');
dragProxy.style.opacity = 70 / 100;
dragProxy.style.filter = 'alpha(opacity=70)';
document.body.appendChild(dragProxy);
dragProxy.style.cssText = document.defaultView.getComputedStyle(element, "").cssText;
return dragProxy;
}

Expand Down