diff --git a/lib/knockout.dragdrop.js b/lib/knockout.dragdrop.js index 74e10dd..cf094bd 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 @@ -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; }