Comparing version 0.6.0 to 0.6.1
@@ -660,8 +660,11 @@ "use strict"; | ||
var targetCHandle = registry.addTarget(Types.FOO, targetC); | ||
var targetD = new NormalTarget(); | ||
var targetDHandle = registry.addTarget([Types.BAZ, Types.FOO], targetD); | ||
backend.simulateBeginDrag(sourceHandle); | ||
backend.simulateHover([targetAHandle, targetBHandle, targetCHandle]); | ||
backend.simulateHover([targetAHandle, targetBHandle, targetCHandle, targetDHandle]); | ||
expect(targetA.didCallHover).to.equal(true); | ||
expect(targetB.didCallHover).to.equal(false); | ||
expect(targetC.didCallHover).to.equal(true); | ||
expect(targetD.didCallHover).to.equal(true); | ||
}); | ||
@@ -668,0 +671,0 @@ |
@@ -595,2 +595,28 @@ "use strict"; | ||
it("correctly handles isOver() for multi-type targets", function () { | ||
var sourceA = new NormalSource(); | ||
var sourceAHandle = registry.addSource(Types.FOO, sourceA); | ||
var sourceB = new NormalSource(); | ||
var sourceBHandle = registry.addSource(Types.BAR, sourceB); | ||
var sourceC = new NormalSource(); | ||
var sourceCHandle = registry.addSource(Types.BAZ, sourceC); | ||
var target = new NormalTarget(); | ||
var targetHandle = registry.addTarget([Types.FOO, Types.BAR], target); | ||
backend.simulateBeginDrag(sourceAHandle); | ||
backend.simulateHover([targetHandle]); | ||
expect(monitor.isOver(targetHandle)).to.equal(true); | ||
expect(monitor.isOver(targetHandle, true)).to.equal(true); | ||
backend.simulateEndDrag(); | ||
backend.simulateBeginDrag(sourceBHandle); | ||
expect(monitor.isOver(targetHandle)).to.equal(true); | ||
expect(monitor.isOver(targetHandle, true)).to.equal(true); | ||
backend.simulateEndDrag(); | ||
backend.simulateBeginDrag(sourceCHandle); | ||
expect(monitor.isOver(targetHandle)).to.equal(false); | ||
expect(monitor.isOver(targetHandle, true)).to.equal(false); | ||
}); | ||
it("does not reset target handles on drop() and endDrag()", function () { | ||
@@ -597,0 +623,0 @@ var source = new NormalSource(); |
@@ -11,2 +11,4 @@ "use strict"; | ||
var matchesType = _interopRequire(require("../utils/matchesType")); | ||
var invariant = _interopRequire(require("invariant")); | ||
@@ -80,3 +82,3 @@ | ||
var targetType = registry.getTargetType(targetHandle); | ||
if (targetType === draggedItemType) { | ||
if (matchesType(targetType, draggedItemType)) { | ||
target.hover(monitor, targetHandle); | ||
@@ -83,0 +85,0 @@ } |
@@ -9,14 +9,4 @@ "use strict"; | ||
var isArray = _interopRequire(require("lodash/lang/isArray")); | ||
var matchesType = _interopRequire(require("./utils/matchesType")); | ||
function matchesType(targetType, draggedItemType) { | ||
if (isArray(targetType)) { | ||
return targetType.some(function (t) { | ||
return t === draggedItemType; | ||
}); | ||
} else { | ||
return targetType === draggedItemType; | ||
} | ||
} | ||
var DragDropMonitor = (function () { | ||
@@ -95,3 +85,3 @@ function DragDropMonitor(flux, registry) { | ||
var draggedItemType = this.getItemType(); | ||
if (draggedItemType !== targetType) { | ||
if (!matchesType(targetType, draggedItemType)) { | ||
return false; | ||
@@ -98,0 +88,0 @@ } |
{ | ||
"name": "dnd-core", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"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
227635
44
2530