@knotx/plugins-drag 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -15
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +11 -15
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -78,7 +78,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
78
78
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
79
79
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
80
80
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
81
|
-
var _destroy_dec, _init_dec, _registerOptionsTransformer_dec, _options_dec, _canvasScale_dec,
|
|
81
|
+
var _destroy_dec, _init_dec, _registerOptionsTransformer_dec, _options_dec, _canvasScale_dec, _interaction_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
|
|
82
82
|
const DEFAULT_OPTIONS = {
|
|
83
83
|
inertia: {
|
|
84
84
|
enabled: true
|
|
@@ -90,22 +90,20 @@ const DEFAULT_OPTIONS = {
|
|
|
90
90
|
})
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
|
-
class Drag extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getNode()], _dispatchNodeOperation_dec = [decorators.inject.dispatchNodeOperation()],
|
|
93
|
+
class Drag extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getNode()], _dispatchNodeOperation_dec = [decorators.inject.dispatchNodeOperation()], _interaction_dec = [decorators.inject.interaction()], _canvasScale_dec = [decorators.inject.canvas.transform((state) => state.scale)], _options_dec = [decorators.register("options")], _registerOptionsTransformer_dec = [decorators.register("registerOptionsTransformer")], _init_dec = [decorators.OnInit], _destroy_dec = [decorators.OnDestroy], _a) {
|
|
94
94
|
constructor() {
|
|
95
95
|
super(...arguments);
|
|
96
96
|
__runInitializers(_init, 5, this);
|
|
97
97
|
__publicField(this, "name", "drag");
|
|
98
98
|
__publicField(this, "getNode", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
99
99
|
__publicField(this, "dispatchNodeOperation", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
100
|
-
__publicField(this, "
|
|
101
|
-
__publicField(this, "
|
|
102
|
-
__publicField(this, "canInteract", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
103
|
-
__publicField(this, "canvasScale", __runInitializers(_init, 28, this, 1)), __runInitializers(_init, 31, this);
|
|
100
|
+
__publicField(this, "interaction", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
101
|
+
__publicField(this, "canvasScale", __runInitializers(_init, 20, this, 1)), __runInitializers(_init, 23, this);
|
|
104
102
|
__publicField(this, "subscription");
|
|
105
103
|
__publicField(this, "transformers$", new rxjs.BehaviorSubject([]));
|
|
106
104
|
__publicField(this, "currentInteractable");
|
|
107
|
-
__publicField(this, "options", __runInitializers(_init,
|
|
108
|
-
__publicField(this, "registerOptionsTransformer", __runInitializers(_init,
|
|
105
|
+
__publicField(this, "options", __runInitializers(_init, 24, this, DEFAULT_OPTIONS)), __runInitializers(_init, 27, this);
|
|
106
|
+
__publicField(this, "registerOptionsTransformer", __runInitializers(_init, 28, this, (transformer) => {
|
|
109
107
|
const transformers = this.transformers$.value;
|
|
110
108
|
transformers.push(transformer);
|
|
111
109
|
this.transformers$.next(transformers);
|
|
@@ -117,7 +115,7 @@ class Drag extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getN
|
|
|
117
115
|
this.transformers$.next(currentTransformers);
|
|
118
116
|
}
|
|
119
117
|
};
|
|
120
|
-
})), __runInitializers(_init,
|
|
118
|
+
})), __runInitializers(_init, 31, this);
|
|
121
119
|
}
|
|
122
120
|
/**
|
|
123
121
|
* 应用所有转换器,生成最终的配置
|
|
@@ -163,7 +161,7 @@ class Drag extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getN
|
|
|
163
161
|
var _a2;
|
|
164
162
|
dragEnd$.next();
|
|
165
163
|
(_a2 = this.currentInteractable) == null ? void 0 : _a2.draggable(this.options);
|
|
166
|
-
this.
|
|
164
|
+
this.interaction.end(this.pluginId, "position");
|
|
167
165
|
};
|
|
168
166
|
this.currentInteractable = interact__default(`.${core.bem("node", "wrapper")}[data-node-id]`).draggable(__spreadProps(__spreadValues({}, this.options), {
|
|
169
167
|
listeners: {
|
|
@@ -175,10 +173,10 @@ class Drag extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getN
|
|
|
175
173
|
dragStart$.next({
|
|
176
174
|
nodeId
|
|
177
175
|
});
|
|
178
|
-
this.
|
|
176
|
+
this.interaction.start(this.pluginId, "position", core.InteractionPriority.EntityPositionDrag);
|
|
179
177
|
},
|
|
180
178
|
move: (event) => {
|
|
181
|
-
if (!this.canInteract(
|
|
179
|
+
if (!this.interaction.canInteract(core.InteractionPriority.EntityPositionDrag)) {
|
|
182
180
|
end();
|
|
183
181
|
return;
|
|
184
182
|
}
|
|
@@ -262,9 +260,7 @@ __decorateElement(_init, 1, "init", _init_dec, Drag);
|
|
|
262
260
|
__decorateElement(_init, 1, "destroy", _destroy_dec, Drag);
|
|
263
261
|
__decorateElement(_init, 5, "getNode", _getNode_dec, Drag);
|
|
264
262
|
__decorateElement(_init, 5, "dispatchNodeOperation", _dispatchNodeOperation_dec, Drag);
|
|
265
|
-
__decorateElement(_init, 5, "
|
|
266
|
-
__decorateElement(_init, 5, "endInteraction", _endInteraction_dec, Drag);
|
|
267
|
-
__decorateElement(_init, 5, "canInteract", _canInteract_dec, Drag);
|
|
263
|
+
__decorateElement(_init, 5, "interaction", _interaction_dec, Drag);
|
|
268
264
|
__decorateElement(_init, 5, "canvasScale", _canvasScale_dec, Drag);
|
|
269
265
|
__decorateElement(_init, 5, "options", _options_dec, Drag);
|
|
270
266
|
__decorateElement(_init, 5, "registerOptionsTransformer", _registerOptionsTransformer_dec, Drag);
|
package/dist/index.d.cts
CHANGED
|
@@ -21,9 +21,7 @@ declare class Drag extends BasePlugin {
|
|
|
21
21
|
name: "drag";
|
|
22
22
|
getNode: Engine['getNode'];
|
|
23
23
|
dispatchNodeOperation: Engine['dispatchNodeOperation'];
|
|
24
|
-
|
|
25
|
-
endInteraction: Engine['endInteraction'];
|
|
26
|
-
canInteract: Engine['canInteract'];
|
|
24
|
+
interaction: Engine['interaction'];
|
|
27
25
|
canvasScale: number;
|
|
28
26
|
private subscription?;
|
|
29
27
|
private transformers$;
|
package/dist/index.d.mts
CHANGED
|
@@ -21,9 +21,7 @@ declare class Drag extends BasePlugin {
|
|
|
21
21
|
name: "drag";
|
|
22
22
|
getNode: Engine['getNode'];
|
|
23
23
|
dispatchNodeOperation: Engine['dispatchNodeOperation'];
|
|
24
|
-
|
|
25
|
-
endInteraction: Engine['endInteraction'];
|
|
26
|
-
canInteract: Engine['canInteract'];
|
|
24
|
+
interaction: Engine['interaction'];
|
|
27
25
|
canvasScale: number;
|
|
28
26
|
private subscription?;
|
|
29
27
|
private transformers$;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,9 +21,7 @@ declare class Drag extends BasePlugin {
|
|
|
21
21
|
name: "drag";
|
|
22
22
|
getNode: Engine['getNode'];
|
|
23
23
|
dispatchNodeOperation: Engine['dispatchNodeOperation'];
|
|
24
|
-
|
|
25
|
-
endInteraction: Engine['endInteraction'];
|
|
26
|
-
canInteract: Engine['canInteract'];
|
|
24
|
+
interaction: Engine['interaction'];
|
|
27
25
|
canvasScale: number;
|
|
28
26
|
private subscription?;
|
|
29
27
|
private transformers$;
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
72
72
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
73
73
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
74
74
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
75
|
-
var _destroy_dec, _init_dec, _registerOptionsTransformer_dec, _options_dec, _canvasScale_dec,
|
|
75
|
+
var _destroy_dec, _init_dec, _registerOptionsTransformer_dec, _options_dec, _canvasScale_dec, _interaction_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
|
|
76
76
|
const DEFAULT_OPTIONS = {
|
|
77
77
|
inertia: {
|
|
78
78
|
enabled: true
|
|
@@ -84,22 +84,20 @@ const DEFAULT_OPTIONS = {
|
|
|
84
84
|
})
|
|
85
85
|
]
|
|
86
86
|
};
|
|
87
|
-
class Drag extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatchNodeOperation_dec = [inject.dispatchNodeOperation()],
|
|
87
|
+
class Drag extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatchNodeOperation_dec = [inject.dispatchNodeOperation()], _interaction_dec = [inject.interaction()], _canvasScale_dec = [inject.canvas.transform((state) => state.scale)], _options_dec = [register("options")], _registerOptionsTransformer_dec = [register("registerOptionsTransformer")], _init_dec = [OnInit], _destroy_dec = [OnDestroy], _a) {
|
|
88
88
|
constructor() {
|
|
89
89
|
super(...arguments);
|
|
90
90
|
__runInitializers(_init, 5, this);
|
|
91
91
|
__publicField(this, "name", "drag");
|
|
92
92
|
__publicField(this, "getNode", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
93
93
|
__publicField(this, "dispatchNodeOperation", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
94
|
-
__publicField(this, "
|
|
95
|
-
__publicField(this, "
|
|
96
|
-
__publicField(this, "canInteract", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
97
|
-
__publicField(this, "canvasScale", __runInitializers(_init, 28, this, 1)), __runInitializers(_init, 31, this);
|
|
94
|
+
__publicField(this, "interaction", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
95
|
+
__publicField(this, "canvasScale", __runInitializers(_init, 20, this, 1)), __runInitializers(_init, 23, this);
|
|
98
96
|
__publicField(this, "subscription");
|
|
99
97
|
__publicField(this, "transformers$", new BehaviorSubject([]));
|
|
100
98
|
__publicField(this, "currentInteractable");
|
|
101
|
-
__publicField(this, "options", __runInitializers(_init,
|
|
102
|
-
__publicField(this, "registerOptionsTransformer", __runInitializers(_init,
|
|
99
|
+
__publicField(this, "options", __runInitializers(_init, 24, this, DEFAULT_OPTIONS)), __runInitializers(_init, 27, this);
|
|
100
|
+
__publicField(this, "registerOptionsTransformer", __runInitializers(_init, 28, this, (transformer) => {
|
|
103
101
|
const transformers = this.transformers$.value;
|
|
104
102
|
transformers.push(transformer);
|
|
105
103
|
this.transformers$.next(transformers);
|
|
@@ -111,7 +109,7 @@ class Drag extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatc
|
|
|
111
109
|
this.transformers$.next(currentTransformers);
|
|
112
110
|
}
|
|
113
111
|
};
|
|
114
|
-
})), __runInitializers(_init,
|
|
112
|
+
})), __runInitializers(_init, 31, this);
|
|
115
113
|
}
|
|
116
114
|
/**
|
|
117
115
|
* 应用所有转换器,生成最终的配置
|
|
@@ -157,7 +155,7 @@ class Drag extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatc
|
|
|
157
155
|
var _a2;
|
|
158
156
|
dragEnd$.next();
|
|
159
157
|
(_a2 = this.currentInteractable) == null ? void 0 : _a2.draggable(this.options);
|
|
160
|
-
this.
|
|
158
|
+
this.interaction.end(this.pluginId, "position");
|
|
161
159
|
};
|
|
162
160
|
this.currentInteractable = interact(`.${bem("node", "wrapper")}[data-node-id]`).draggable(__spreadProps(__spreadValues({}, this.options), {
|
|
163
161
|
listeners: {
|
|
@@ -169,10 +167,10 @@ class Drag extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatc
|
|
|
169
167
|
dragStart$.next({
|
|
170
168
|
nodeId
|
|
171
169
|
});
|
|
172
|
-
this.
|
|
170
|
+
this.interaction.start(this.pluginId, "position", InteractionPriority.EntityPositionDrag);
|
|
173
171
|
},
|
|
174
172
|
move: (event) => {
|
|
175
|
-
if (!this.canInteract(
|
|
173
|
+
if (!this.interaction.canInteract(InteractionPriority.EntityPositionDrag)) {
|
|
176
174
|
end();
|
|
177
175
|
return;
|
|
178
176
|
}
|
|
@@ -256,9 +254,7 @@ __decorateElement(_init, 1, "init", _init_dec, Drag);
|
|
|
256
254
|
__decorateElement(_init, 1, "destroy", _destroy_dec, Drag);
|
|
257
255
|
__decorateElement(_init, 5, "getNode", _getNode_dec, Drag);
|
|
258
256
|
__decorateElement(_init, 5, "dispatchNodeOperation", _dispatchNodeOperation_dec, Drag);
|
|
259
|
-
__decorateElement(_init, 5, "
|
|
260
|
-
__decorateElement(_init, 5, "endInteraction", _endInteraction_dec, Drag);
|
|
261
|
-
__decorateElement(_init, 5, "canInteract", _canInteract_dec, Drag);
|
|
257
|
+
__decorateElement(_init, 5, "interaction", _interaction_dec, Drag);
|
|
262
258
|
__decorateElement(_init, 5, "canvasScale", _canvasScale_dec, Drag);
|
|
263
259
|
__decorateElement(_init, 5, "options", _options_dec, Drag);
|
|
264
260
|
__decorateElement(_init, 5, "registerOptionsTransformer", _registerOptionsTransformer_dec, Drag);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/plugins-drag",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Drag Plugin for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@knotx/jsx": "0.3.
|
|
32
|
-
"@knotx/plugins-canvas": "0.3.
|
|
31
|
+
"@knotx/jsx": "0.3.3",
|
|
32
|
+
"@knotx/plugins-canvas": "0.3.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@interactjs/actions": "^1.10.27",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"@interactjs/types": "^1.10.27",
|
|
39
39
|
"interactjs": "^1.10.27",
|
|
40
40
|
"rxjs": "^7.8.1",
|
|
41
|
-
"@knotx/core": "0.3.
|
|
42
|
-
"@knotx/decorators": "0.3.
|
|
41
|
+
"@knotx/core": "0.3.3",
|
|
42
|
+
"@knotx/decorators": "0.3.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@knotx/build-config": "0.3.
|
|
46
|
-
"@knotx/eslint-config": "0.3.
|
|
47
|
-
"@knotx/jsx": "0.3.
|
|
48
|
-
"@knotx/plugins-canvas": "0.3.
|
|
49
|
-
"@knotx/typescript-config": "0.3.
|
|
45
|
+
"@knotx/build-config": "0.3.3",
|
|
46
|
+
"@knotx/eslint-config": "0.3.3",
|
|
47
|
+
"@knotx/jsx": "0.3.3",
|
|
48
|
+
"@knotx/plugins-canvas": "0.3.3",
|
|
49
|
+
"@knotx/typescript-config": "0.3.3"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "unbuild",
|