@leafer-ui/interaction 1.0.4 → 1.0.6
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/package.json +9 -9
- package/src/Dragger.ts +12 -11
- package/src/Interaction.ts +3 -2
- package/src/config.ts +1 -0
- package/types/index.d.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interaction",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "@leafer-ui/interaction",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,21 +13,21 @@
|
|
|
13
13
|
],
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/leaferjs/ui.git"
|
|
16
|
+
"url": "https://github.com/leaferjs/leafer-ui.git"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/leaferjs/ui/tree/main/packages/interaction/interaction",
|
|
19
|
-
"bugs": "https://github.com/leaferjs/ui/issues",
|
|
18
|
+
"homepage": "https://github.com/leaferjs/leafer-ui/tree/main/packages/interaction/interaction",
|
|
19
|
+
"bugs": "https://github.com/leaferjs/leafer-ui/issues",
|
|
20
20
|
"keywords": [
|
|
21
21
|
"leafer-ui",
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.
|
|
26
|
-
"@leafer-ui/draw": "1.0.
|
|
27
|
-
"@leafer-ui/event": "1.0.
|
|
25
|
+
"@leafer/core": "1.0.6",
|
|
26
|
+
"@leafer-ui/draw": "1.0.6",
|
|
27
|
+
"@leafer-ui/event": "1.0.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.
|
|
31
|
-
"@leafer-ui/interface": "1.0.
|
|
30
|
+
"@leafer/interface": "1.0.6",
|
|
31
|
+
"@leafer-ui/interface": "1.0.6"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Dragger.ts
CHANGED
|
@@ -20,8 +20,8 @@ export class Dragger {
|
|
|
20
20
|
public dragData: IDragEvent
|
|
21
21
|
protected downData: IPointerEvent
|
|
22
22
|
|
|
23
|
-
public
|
|
24
|
-
public
|
|
23
|
+
public draggableList: ILeafList
|
|
24
|
+
public realDraggableList: ILeafList
|
|
25
25
|
protected dragOverPath: ILeafList
|
|
26
26
|
protected dragEnterPath: ILeafList
|
|
27
27
|
|
|
@@ -43,9 +43,10 @@ export class Dragger {
|
|
|
43
43
|
this.canAnimate = this.canDragOut = true
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
public getList(): ILeafList {
|
|
46
|
+
public getList(realDraggable?: boolean, hover?: boolean): ILeafList {
|
|
47
47
|
const { proxy } = this.interaction.selector
|
|
48
|
-
|
|
48
|
+
const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList
|
|
49
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList) // realDraggable 需排除代理选择器,它有自身的拖拽逻辑
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
public checkDrag(data: IPointerEvent, canDrag: boolean): void {
|
|
@@ -76,8 +77,8 @@ export class Dragger {
|
|
|
76
77
|
this.dragging = canDrag && PointerButton.left(data)
|
|
77
78
|
if (this.dragging) {
|
|
78
79
|
this.interaction.emit(DragEvent.START, this.dragData)
|
|
79
|
-
this.
|
|
80
|
-
this.setDragStartPoints(this.
|
|
80
|
+
this.getDraggableList(this.dragData.path)
|
|
81
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true))
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -87,12 +88,12 @@ export class Dragger {
|
|
|
87
88
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y })
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
protected
|
|
91
|
+
protected getDraggableList(path: ILeafList): void {
|
|
91
92
|
let leaf: ILeaf
|
|
92
93
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
93
94
|
leaf = path.list[i]
|
|
94
|
-
if ((leaf.
|
|
95
|
-
this.
|
|
95
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
96
|
+
this.draggableList = new LeafList(leaf)
|
|
96
97
|
break
|
|
97
98
|
}
|
|
98
99
|
}
|
|
@@ -118,7 +119,7 @@ export class Dragger {
|
|
|
118
119
|
|
|
119
120
|
protected dragReal(): void {
|
|
120
121
|
const { running } = this.interaction
|
|
121
|
-
const list = this.
|
|
122
|
+
const list = this.realDraggableList
|
|
122
123
|
if (list.length && running) {
|
|
123
124
|
const { totalX, totalY } = this.dragData
|
|
124
125
|
list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })))
|
|
@@ -221,7 +222,7 @@ export class Dragger {
|
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
protected dragReset(): void {
|
|
224
|
-
DragEvent.list = DragEvent.data = this.
|
|
225
|
+
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
|
package/src/Interaction.ts
CHANGED
|
@@ -201,6 +201,7 @@ export class InteractionBase implements IInteraction {
|
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
public multiTouch(data: IUIEvent, list: IKeepTouchData[]): void {
|
|
204
|
+
if (this.config.multiTouch.disabled) return
|
|
204
205
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list)
|
|
205
206
|
this.rotate(getRotateEventData(center, angle, data))
|
|
206
207
|
this.zoom(getZoomEventData(center, scale, data))
|
|
@@ -425,7 +426,7 @@ export class InteractionBase implements IInteraction {
|
|
|
425
426
|
public updateHoverData(data?: IPointerEvent): void {
|
|
426
427
|
if (!data) data = this.hoverData
|
|
427
428
|
if (!data) return
|
|
428
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE })
|
|
429
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE })
|
|
429
430
|
this.hoverData = data
|
|
430
431
|
}
|
|
431
432
|
|
|
@@ -448,7 +449,7 @@ export class InteractionBase implements IInteraction {
|
|
|
448
449
|
const { path } = data
|
|
449
450
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
450
451
|
leaf = path.list[i]
|
|
451
|
-
cursor = leaf.syncEventer
|
|
452
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor
|
|
452
453
|
if (cursor) break
|
|
453
454
|
}
|
|
454
455
|
|
package/src/config.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ declare class Dragger {
|
|
|
26
26
|
dragging: boolean;
|
|
27
27
|
dragData: IDragEvent;
|
|
28
28
|
protected downData: IPointerEvent;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
draggableList: ILeafList;
|
|
30
|
+
realDraggableList: ILeafList;
|
|
31
31
|
protected dragOverPath: ILeafList;
|
|
32
32
|
protected dragEnterPath: ILeafList;
|
|
33
33
|
protected dragStartPoints: IPointDataMap;
|
|
@@ -37,11 +37,11 @@ declare class Dragger {
|
|
|
37
37
|
protected animateWait: IFunction;
|
|
38
38
|
constructor(interaction: InteractionBase);
|
|
39
39
|
setDragData(data: IPointerEvent): void;
|
|
40
|
-
getList(): ILeafList;
|
|
40
|
+
getList(realDraggable?: boolean, hover?: boolean): ILeafList;
|
|
41
41
|
checkDrag(data: IPointerEvent, canDrag: boolean): void;
|
|
42
42
|
dragStart(data: IPointerEvent, canDrag: boolean): void;
|
|
43
43
|
protected setDragStartPoints(list: ILeafList | ILeaf[]): void;
|
|
44
|
-
protected
|
|
44
|
+
protected getDraggableList(path: ILeafList): void;
|
|
45
45
|
protected drag(data: IPointerEvent): void;
|
|
46
46
|
protected dragReal(): void;
|
|
47
47
|
dragOverOrOut(data: IPointerEvent): void;
|