Comparing version 0.5.4 to 0.5.5
@@ -206,2 +206,27 @@ "use strict"; | ||
}); | ||
it("accurately reports handler role", function () { | ||
var source = new NormalSource(); | ||
var sourceHandle = registry.addSource(Types.FOO, source); | ||
var target = new NormalTarget(); | ||
var targetHandle = registry.addTarget(Types.FOO, target); | ||
expect(registry.isSourceHandle(sourceHandle)).to.equal(true); | ||
expect(registry.isSourceHandle(targetHandle)).to.equal(false); | ||
expect(function () { | ||
return registry.isSourceHandle("something else"); | ||
}).to.throwError(); | ||
expect(function () { | ||
return registry.isSourceHandle(null); | ||
}).to.throwError(); | ||
expect(registry.isTargetHandle(sourceHandle)).to.equal(false); | ||
expect(registry.isTargetHandle(targetHandle)).to.equal(true); | ||
expect(function () { | ||
return registry.isTargetHandle("something else"); | ||
}).to.throwError(); | ||
expect(function () { | ||
return registry.isTargetHandle(null); | ||
}).to.throwError(); | ||
}); | ||
}); | ||
@@ -208,0 +233,0 @@ |
@@ -363,2 +363,4 @@ "use strict"; | ||
it("keeps track of target handles", function () { | ||
var source = new NormalSource(); | ||
var sourceHandle = registry.addSource(Types.FOO, source); | ||
var targetA = new NormalTarget(); | ||
@@ -378,2 +380,13 @@ var targetAHandle = registry.addTarget(Types.FOO, targetA); | ||
expect(handles[0]).to.equal(targetAHandle); | ||
expect(monitor.isOver(targetAHandle)).to.equal(false); | ||
expect(monitor.isOver(targetAHandle, true)).to.equal(false); | ||
expect(monitor.isOver(targetBHandle)).to.equal(false); | ||
expect(monitor.isOver(targetBHandle, true)).to.equal(false); | ||
expect(monitor.isOver(targetCHandle)).to.equal(false); | ||
expect(monitor.isOver(targetCHandle, true)).to.equal(false); | ||
backend.simulateBeginDrag(sourceHandle); | ||
handles = monitor.getTargetHandles(); | ||
expect(handles.length).to.be(1); | ||
expect(handles[0]).to.equal(targetAHandle); | ||
expect(monitor.isOver(targetAHandle)).to.equal(true); | ||
@@ -423,2 +436,3 @@ expect(monitor.isOver(targetAHandle, true)).to.equal(true); | ||
backend.simulateHover([targetBHandle]); | ||
backend.simulateDrop(); | ||
handles = monitor.getTargetHandles(); | ||
@@ -433,2 +447,12 @@ expect(handles[0]).to.equal(targetBHandle); | ||
expect(monitor.isOver(targetCHandle, true)).to.equal(false); | ||
backend.simulateEndDrag(); | ||
expect(handles[0]).to.equal(targetBHandle); | ||
expect(handles.length).to.be(1); | ||
expect(monitor.isOver(targetAHandle)).to.equal(false); | ||
expect(monitor.isOver(targetAHandle, true)).to.equal(false); | ||
expect(monitor.isOver(targetBHandle)).to.equal(false); | ||
expect(monitor.isOver(targetBHandle, true)).to.equal(false); | ||
expect(monitor.isOver(targetCHandle)).to.equal(false); | ||
expect(monitor.isOver(targetCHandle, true)).to.equal(false); | ||
}); | ||
@@ -435,0 +459,0 @@ |
@@ -88,2 +88,6 @@ "use strict"; | ||
if (!this.isDragging()) { | ||
return false; | ||
} | ||
var targetHandles = this.getTargetHandles(); | ||
@@ -90,0 +94,0 @@ if (!targetHandles.length) { |
@@ -34,2 +34,4 @@ "use strict"; | ||
invariant(type && role && id, "Invalid handle."); | ||
if (type.indexOf(TYPE_SEPARATOR) > -1) { | ||
@@ -174,2 +176,18 @@ type = type.split(TYPE_SEPARATOR); | ||
HandlerRegistry.prototype.isSourceHandle = function isSourceHandle(handle) { | ||
var _parseHandle = parseHandle(handle); | ||
var role = _parseHandle.role; | ||
return role === HandlerRoles.SOURCE; | ||
}; | ||
HandlerRegistry.prototype.isTargetHandle = function isTargetHandle(handle) { | ||
var _parseHandle = parseHandle(handle); | ||
var role = _parseHandle.role; | ||
return role === HandlerRoles.TARGET; | ||
}; | ||
HandlerRegistry.prototype.removeSource = function removeSource(sourceHandle) { | ||
@@ -176,0 +194,0 @@ validateSourceHandle(sourceHandle); |
{ | ||
"name": "dnd-core", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"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
215928
2294