Comparing version 0.5.1 to 0.5.3
@@ -136,3 +136,3 @@ "use strict"; | ||
var source = new NormalSource(); | ||
var sourceHandle = registry.addSource(Types.FOO, source); | ||
registry.addSource(Types.FOO, source); | ||
@@ -149,3 +149,3 @@ expect(function () { | ||
var target = new NormalTarget(); | ||
var targetHandle = registry.addTarget(Types.FOO, target); | ||
registry.addTarget(Types.FOO, target); | ||
@@ -152,0 +152,0 @@ expect(function () { |
@@ -293,2 +293,50 @@ "use strict"; | ||
}); | ||
it("returns false from isDragging(sourceHandle) if source is not published", function () { | ||
var source = new NormalSource(); | ||
var sourceHandle = registry.addSource(Types.FOO, source); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulateBeginDrag(sourceHandle, false); | ||
expect(monitor.isDragging()).to.equal(true); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulatePublishDragSource(); | ||
expect(monitor.isDragging()).to.equal(true); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(true); | ||
backend.simulateEndDrag(); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
}); | ||
it("ignores publishDragSource() outside dragging operation", function () { | ||
var source = new NormalSource(); | ||
var sourceHandle = registry.addSource(Types.FOO, source); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulatePublishDragSource(); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulateBeginDrag(sourceHandle, false); | ||
expect(monitor.isDragging()).to.equal(true); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulatePublishDragSource(); | ||
expect(monitor.isDragging()).to.equal(true); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(true); | ||
backend.simulateEndDrag(); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
backend.simulatePublishDragSource(); | ||
expect(monitor.isDragging()).to.equal(false); | ||
expect(monitor.isDragging(sourceHandle)).to.equal(false); | ||
}); | ||
}); | ||
@@ -295,0 +343,0 @@ |
@@ -28,2 +28,4 @@ "use strict"; | ||
DragDropActions.prototype.beginDrag = function beginDrag(sourceHandle) { | ||
var isSourcePublic = arguments[1] === undefined ? true : arguments[1]; | ||
var monitor = this.manager.getMonitor(); | ||
@@ -43,5 +45,14 @@ var registry = this.manager.getRegistry(); | ||
var itemType = registry.getSourceType(sourceHandle); | ||
return { itemType: itemType, item: item, sourceHandle: sourceHandle }; | ||
return { itemType: itemType, item: item, sourceHandle: sourceHandle, isSourcePublic: isSourcePublic }; | ||
}; | ||
DragDropActions.prototype.publishDragSource = function publishDragSource() { | ||
var monitor = this.manager.getMonitor(); | ||
if (!monitor.isDragging()) { | ||
return; | ||
} | ||
return {}; | ||
}; | ||
DragDropActions.prototype.hover = function hover(targetHandles) { | ||
@@ -48,0 +59,0 @@ invariant(isArray(targetHandles), "Target handles must be an array."); |
@@ -21,6 +21,10 @@ "use strict"; | ||
TestBackend.prototype.simulateBeginDrag = function simulateBeginDrag(sourceHandle) { | ||
this.actions.beginDrag(sourceHandle); | ||
TestBackend.prototype.simulateBeginDrag = function simulateBeginDrag(sourceHandle, isSourcePublic) { | ||
this.actions.beginDrag(sourceHandle, isSourcePublic); | ||
}; | ||
TestBackend.prototype.simulatePublishDragSource = function simulatePublishDragSource() { | ||
this.actions.publishDragSource(); | ||
}; | ||
TestBackend.prototype.simulateHover = function simulateHover(targetHandles) { | ||
@@ -27,0 +31,0 @@ this.actions.hover(targetHandles); |
@@ -22,3 +22,3 @@ "use strict"; | ||
this.monitor = new DragDropMonitor(flux, this.registry); | ||
this.backend = new Backend(flux.dragDropActions, this.monitor); | ||
this.backend = new Backend(flux.dragDropActions, this.monitor, this.registry); | ||
@@ -25,0 +25,0 @@ flux.refCountStore.addListener("change", this.handleRefCountChange, this); |
@@ -73,2 +73,6 @@ "use strict"; | ||
if (!this.isSourcePublic()) { | ||
return false; | ||
} | ||
var source = this.registry.getSource(sourceHandle, true); | ||
@@ -122,2 +126,6 @@ if (!source) { | ||
DragDropMonitor.prototype.isSourcePublic = function isSourcePublic() { | ||
return this.dragOperationStore.isSourcePublic(); | ||
}; | ||
return DragDropMonitor; | ||
@@ -124,0 +132,0 @@ })(); |
@@ -23,2 +23,3 @@ "use strict"; | ||
this.register(dragDropActionIds.beginDrag, this.handleBeginDrag); | ||
this.register(dragDropActionIds.publishDragSource, this.handlePublishDragSource); | ||
this.register(dragDropActionIds.hover, this.handleHover); | ||
@@ -35,3 +36,4 @@ this.register(dragDropActionIds.endDrag, this.handleEndDrag); | ||
dropResult: null, | ||
didDrop: false | ||
didDrop: false, | ||
isSourcePublic: null | ||
}; | ||
@@ -46,2 +48,3 @@ } | ||
var sourceHandle = _ref.sourceHandle; | ||
var isSourcePublic = _ref.isSourcePublic; | ||
@@ -52,2 +55,3 @@ this.setState({ | ||
sourceHandle: sourceHandle, | ||
isSourcePublic: isSourcePublic, | ||
dropResult: false, | ||
@@ -58,2 +62,6 @@ didDrop: false | ||
DragOperationStore.prototype.handlePublishDragSource = function handlePublishDragSource() { | ||
this.setState({ isSourcePublic: true }); | ||
}; | ||
DragOperationStore.prototype.handleHover = function handleHover(_ref) { | ||
@@ -91,3 +99,4 @@ var targetHandles = _ref.targetHandles; | ||
dropResult: null, | ||
didDrop: false | ||
didDrop: false, | ||
isSourcePublic: null | ||
}); | ||
@@ -124,2 +133,6 @@ }; | ||
DragOperationStore.prototype.isSourcePublic = function isSourcePublic() { | ||
return this.state.isSourcePublic; | ||
}; | ||
return DragOperationStore; | ||
@@ -126,0 +139,0 @@ })(Store); |
{ | ||
"name": "dnd-core", | ||
"version": "0.5.1", | ||
"version": "0.5.3", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -5,0 +5,0 @@ "main": "dist-modules/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212552
2224