Comparing version 0.4.1 to 0.4.2
@@ -131,2 +131,21 @@ "use strict"; | ||
}); | ||
it("calls setup() and teardown() on backend", function () { | ||
expect(backend.isActive).to.equal(undefined); | ||
var sourceHandle = registry.addSource(Types.FOO, new NormalSource()); | ||
expect(backend.isActive).to.equal(true); | ||
var targetHandle = registry.addTarget(Types.FOO, new NormalTarget()); | ||
expect(backend.isActive).to.equal(true); | ||
registry.removeSource(sourceHandle); | ||
expect(backend.isActive).to.equal(true); | ||
registry.removeTarget(targetHandle); | ||
expect(backend.isActive).to.equal(false); | ||
registry.addTarget(Types.BAR, new NormalTarget()); | ||
expect(backend.isActive).to.equal(true); | ||
}); | ||
}); | ||
@@ -133,0 +152,0 @@ |
@@ -28,3 +28,2 @@ "use strict"; | ||
var registry = this.manager.getRegistry(); | ||
invariant(!monitor.isDragging(), "Cannot call beginDrag while dragging."); | ||
@@ -31,0 +30,0 @@ if (!monitor.canDrag(sourceHandle)) { |
@@ -10,4 +10,13 @@ "use strict"; | ||
this.actions = actions; | ||
this.isActive = undefined; | ||
} | ||
TestBackend.prototype.setup = function setup() { | ||
this.isActive = true; | ||
}; | ||
TestBackend.prototype.teardown = function teardown() { | ||
this.isActive = false; | ||
}; | ||
TestBackend.prototype.simulateBeginDrag = function simulateBeginDrag(sourceHandle) { | ||
@@ -14,0 +23,0 @@ this.actions.beginDrag(sourceHandle); |
@@ -23,4 +23,14 @@ "use strict"; | ||
this.backend = new Backend(flux.dragDropActions); | ||
flux.refCountStore.addListener("change", this.handleRefCountChange, this); | ||
} | ||
DragDropManager.prototype.handleRefCountChange = function handleRefCountChange() { | ||
if (this.flux.refCountStore.hasRefs()) { | ||
this.backend.setup(); | ||
} else { | ||
this.backend.teardown(); | ||
} | ||
}; | ||
DragDropManager.prototype.getMonitor = function getMonitor() { | ||
@@ -27,0 +37,0 @@ return this.monitor; |
@@ -17,2 +17,4 @@ "use strict"; | ||
var RefCountStore = _interopRequire(require("./stores/RefCountStore")); | ||
var Flux = (function (_Flummox) { | ||
@@ -34,2 +36,5 @@ function Flux(manager) { | ||
this.dragOperationStore = this.getStore("dragOperationStore"); | ||
this.createStore("refCountStore", RefCountStore, this); | ||
this.refCountStore = this.getStore("refCountStore"); | ||
} | ||
@@ -36,0 +41,0 @@ |
{ | ||
"name": "dnd-core", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -5,0 +5,0 @@ "main": "dist-modules/index.js", |
@@ -1,8 +0,7 @@ | ||
# dnd-core | ||
# dnd-core [![npm package](https://img.shields.io/npm/v/dnd-core.svg?style=flat-square)](https://www.npmjs.org/package/dnd-core) [![Build Status](https://travis-ci.org/gaearon/dnd-core.svg?branch=master)](https://travis-ci.org/gaearon/dnd-core) [![Test Coverage](https://codeclimate.com/github/gaearon/dnd-core/badges/coverage.svg)](https://codeclimate.com/github/gaearon/dnd-core) [![Join the chat at https://gitter.im/gaearon/dnd-core](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gaearon/dnd-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Drag and drop sans the GUI. | ||
Work in progress. | ||
[![Join the chat at https://gitter.im/gaearon/react-dnd](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gaearon/react-dnd?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
This is a clean re-implementation of drag and drop primitives and will eventually become core of [React DnD](https://github.com/gaearon/react-dnd). | ||
@@ -9,0 +8,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
311088
41
2026
33