Comparing version
@@ -15,3 +15,3 @@ import { Backend, BackendFactory, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from './interfaces'; | ||
dispatch(action: any): void; | ||
private handleRefCountChange(); | ||
private handleRefCountChange; | ||
} |
@@ -11,4 +11,16 @@ "use strict"; | ||
if (context === void 0) { context = {}; } | ||
var _this = this; | ||
this.context = context; | ||
this.isSetUp = false; | ||
this.handleRefCountChange = function () { | ||
var shouldSetUp = _this.store.getState().refCount > 0; | ||
if (shouldSetUp && !_this.isSetUp) { | ||
_this.backend.setup(); | ||
_this.isSetUp = true; | ||
} | ||
else if (!shouldSetUp && _this.isSetUp) { | ||
_this.backend.teardown(); | ||
_this.isSetUp = false; | ||
} | ||
}; | ||
var store = redux_1.createStore(reducers_1.default); | ||
@@ -18,3 +30,3 @@ this.store = store; | ||
this.backend = createBackend(this); | ||
store.subscribe(this.handleRefCountChange.bind(this)); | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
@@ -58,15 +70,4 @@ DragDropManagerImpl.prototype.getContext = function () { | ||
}; | ||
DragDropManagerImpl.prototype.handleRefCountChange = function () { | ||
var shouldSetUp = this.store.getState().refCount > 0; | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
} | ||
else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
}; | ||
return DragDropManagerImpl; | ||
}()); | ||
exports.default = DragDropManagerImpl; |
@@ -25,3 +25,3 @@ import { Store } from 'redux'; | ||
unpinSource(): void; | ||
private addHandler(role, type, handler); | ||
private addHandler; | ||
} |
@@ -13,3 +13,3 @@ import { Unsubscribe } from 'redux'; | ||
SOURCE = "SOURCE", | ||
TARGET = "TARGET", | ||
TARGET = "TARGET" | ||
} | ||
@@ -113,2 +113,6 @@ export interface Backend { | ||
export declare type ActionCreator<Payload> = (args: any[]) => Action<Payload>; | ||
export interface InitCoordsOptions { | ||
clientOffset?: XYCoord; | ||
getSourceClientOffset?: (sourceId: Identifier) => XYCoord; | ||
} | ||
export interface BeginDragOptions { | ||
@@ -119,2 +123,6 @@ publishSource?: boolean; | ||
} | ||
export interface InitCoordsPayload { | ||
clientOffset: XYCoord | null; | ||
sourceClientOffset: XYCoord | null; | ||
} | ||
export interface BeginDragPayload { | ||
@@ -145,2 +153,3 @@ itemType: Identifier; | ||
export interface DragDropActions { | ||
initCoords(sourceIds: string[], options?: any): Action<InitCoordsPayload>; | ||
beginDrag(sourceIds: string[], options?: any): Action<BeginDragPayload>; | ||
@@ -147,0 +156,0 @@ publishDragSource(): SentinelAction; |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
@@ -22,2 +25,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
switch (action.type) { | ||
case dragDrop_1.INIT_COORDS: | ||
case dragDrop_1.BEGIN_DRAG: | ||
@@ -24,0 +28,0 @@ return { |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
@@ -10,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
@@ -10,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "dnd-core", | ||
"version": "4.0.5", | ||
"version": "6.0.0", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -22,11 +22,11 @@ "license": "BSD-3-Clause", | ||
"invariant": "^2.2.4", | ||
"lodash": "^4.17.10", | ||
"redux": "^4.0.0" | ||
"lodash": "^4.17.11", | ||
"redux": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "10.3.2", | ||
"npm-run-all": "^4.1.2", | ||
"npm-run-all": "^4.1.3", | ||
"rimraf": "^2.6.2", | ||
"typescript": "^2.8.1" | ||
} | ||
"typescript": "^3.1.6" | ||
}, | ||
"gitHead": "21b878d2c66f020aa5248b085f4438b59e9c935b" | ||
} |
63109
13.06%3
-25%57
32.56%1489
13.93%Updated
Updated