@leafer-ui/interaction 1.0.0-rc.20 → 1.0.0-rc.22
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 +6 -6
- package/src/Dragger.ts +12 -4
- package/src/Interaction.ts +7 -4
- package/types/index.d.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interaction",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.22",
|
|
4
4
|
"description": "@leafer-ui/interaction",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.0-rc.
|
|
26
|
-
"@leafer-ui/draw": "1.0.0-rc.
|
|
27
|
-
"@leafer-ui/event": "1.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.22",
|
|
26
|
+
"@leafer-ui/draw": "1.0.0-rc.22",
|
|
27
|
+
"@leafer-ui/event": "1.0.0-rc.22"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.0-rc.
|
|
31
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
30
|
+
"@leafer/interface": "1.0.0-rc.22",
|
|
31
|
+
"@leafer-ui/interface": "1.0.0-rc.22"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Dragger.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointerEvent, IDragEvent, ILeaf, ILeafList, ITimer, IFunction } from '@leafer/interface'
|
|
1
|
+
import { IPointerEvent, IDragEvent, ILeaf, ILeafList, ITimer, IFunction, IPointDataMap } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, PointHelper, LeafList } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { MoveEvent, DragEvent, DropEvent, PointerButton } from '@leafer-ui/event'
|
|
@@ -21,9 +21,11 @@ export class Dragger {
|
|
|
21
21
|
protected downData: IPointerEvent
|
|
22
22
|
|
|
23
23
|
public dragableList: ILeafList
|
|
24
|
+
public realDragableList: ILeafList
|
|
24
25
|
protected dragOverPath: ILeafList
|
|
25
26
|
protected dragEnterPath: ILeafList
|
|
26
27
|
|
|
28
|
+
protected dragStartPoints: IPointDataMap
|
|
27
29
|
protected autoMoveTimer: ITimer
|
|
28
30
|
|
|
29
31
|
public canAnimate: boolean
|
|
@@ -72,10 +74,16 @@ export class Dragger {
|
|
|
72
74
|
if (this.dragging) {
|
|
73
75
|
this.interaction.emit(DragEvent.START, this.dragData)
|
|
74
76
|
this.getDragableList(this.dragData.path)
|
|
77
|
+
this.setDragStartPoints(this.realDragableList = this.getList())
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
protected setDragStartPoints(list: ILeafList | ILeaf[]): void {
|
|
83
|
+
this.dragStartPoints = {}
|
|
84
|
+
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y })
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
protected getDragableList(path: ILeafList): void {
|
|
80
88
|
let leaf: ILeaf
|
|
81
89
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
@@ -106,10 +114,10 @@ export class Dragger {
|
|
|
106
114
|
|
|
107
115
|
protected dragReal(): void {
|
|
108
116
|
const { running } = this.interaction
|
|
109
|
-
const list = this.
|
|
117
|
+
const list = this.realDragableList
|
|
110
118
|
if (list.length && running) {
|
|
111
|
-
const {
|
|
112
|
-
list.forEach(leaf => leaf.draggable && leaf.
|
|
119
|
+
const { totalX, totalY } = this.dragData
|
|
120
|
+
list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })))
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
|
package/src/Interaction.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUIEvent, IPointerEvent, ILeaf, IInteraction, IInteractionConfig, ILeafList, IMoveEvent, IZoomEvent, IRotateEvent, ISelector, IBounds, IEventListenerId, IInteractionCanvas, ITimer, IKeepTouchData, IKeyEvent, IPickOptions, ICursorType, IBooleanMap } from '@leafer/interface'
|
|
1
|
+
import { IUIEvent, IPointerEvent, ILeaf, IInteraction, IInteractionConfig, ILeafList, IMoveEvent, IZoomEvent, IRotateEvent, ISelector, IBounds, IEventListenerId, IInteractionCanvas, ITimer, IKeepTouchData, IKeyEvent, IPickOptions, ICursorType, IBooleanMap, IPickBottom } from '@leafer/interface'
|
|
2
2
|
import { LeaferEvent, ResizeEvent, LeafList, Bounds, PointHelper, DataHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IApp } from '@leafer-ui/interface'
|
|
@@ -35,6 +35,8 @@ export class InteractionBase implements IInteraction {
|
|
|
35
35
|
public cursor: ICursorType | ICursorType[]
|
|
36
36
|
public get hitRadius(): number { return this.config.pointer.hitRadius }
|
|
37
37
|
|
|
38
|
+
public bottomList?: IPickBottom[]
|
|
39
|
+
|
|
38
40
|
public shrinkCanvasBounds: IBounds
|
|
39
41
|
|
|
40
42
|
public downData: IPointerEvent
|
|
@@ -346,7 +348,8 @@ export class InteractionBase implements IInteraction {
|
|
|
346
348
|
// update
|
|
347
349
|
public findPath(data: IPointerEvent, options?: IPickOptions): ILeafList {
|
|
348
350
|
const { hitRadius, through } = this.config.pointer
|
|
349
|
-
const
|
|
351
|
+
const { bottomList } = this
|
|
352
|
+
const find = this.selector.getByPoint(data, hitRadius, { bottomList, name: data.type, ...(options || { through }) })
|
|
350
353
|
if (find.throughPath) data.throughPath = find.throughPath
|
|
351
354
|
data.path = find.path
|
|
352
355
|
return find.path
|
|
@@ -359,7 +362,7 @@ export class InteractionBase implements IInteraction {
|
|
|
359
362
|
public isTreePath(data: IPointerEvent): boolean {
|
|
360
363
|
const app = this.target.app as IApp
|
|
361
364
|
if (!app || !app.isApp) return false
|
|
362
|
-
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree)) // 当dragEmpty为true时,在手机端(pointer.hover为false)可以拖动tree层(编辑器选中的元素除外)
|
|
365
|
+
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !(data.target as ILeaf).syncEventer) // 当dragEmpty为true时,在手机端(pointer.hover为false)可以拖动tree层(编辑器选中的元素除外)
|
|
363
366
|
}
|
|
364
367
|
|
|
365
368
|
protected checkPath(data: IPointerEvent, useDefaultPath?: boolean): void {
|
|
@@ -432,7 +435,7 @@ export class InteractionBase implements IInteraction {
|
|
|
432
435
|
const { path } = data
|
|
433
436
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
434
437
|
leaf = path.list[i]
|
|
435
|
-
cursor = leaf.cursor
|
|
438
|
+
cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor
|
|
436
439
|
if (cursor) break
|
|
437
440
|
}
|
|
438
441
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent, ILeafList,
|
|
1
|
+
import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent, ILeafList, IPointDataMap, IFunction, ILeaf, IInteraction, IInteractionCanvas, ISelector, IInteractionConfig, ICursorType, IPickBottom, IBounds, IEventListenerId, IBooleanMap, IUIEvent, IKeepTouchData, IKeyEvent, IPickOptions, IPointData, IEvent, IObject, IDropEvent, ISwipeEvent, IMultiTouchData, ICursorTypeMap, IHitCanvasManager, ILeaferCanvasConfig, IHitCanvas } from '@leafer/interface';
|
|
2
2
|
import { LeafList, CanvasManager } from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
declare class Transformer {
|
|
@@ -26,8 +26,10 @@ declare class Dragger {
|
|
|
26
26
|
dragData: IDragEvent;
|
|
27
27
|
protected downData: IPointerEvent;
|
|
28
28
|
dragableList: ILeafList;
|
|
29
|
+
realDragableList: ILeafList;
|
|
29
30
|
protected dragOverPath: ILeafList;
|
|
30
31
|
protected dragEnterPath: ILeafList;
|
|
32
|
+
protected dragStartPoints: IPointDataMap;
|
|
31
33
|
protected autoMoveTimer: ITimer;
|
|
32
34
|
canAnimate: boolean;
|
|
33
35
|
canDragOut: boolean;
|
|
@@ -37,6 +39,7 @@ declare class Dragger {
|
|
|
37
39
|
getList(): ILeafList;
|
|
38
40
|
checkDrag(data: IPointerEvent, canDrag: boolean): void;
|
|
39
41
|
dragStart(data: IPointerEvent, canDrag: boolean): void;
|
|
42
|
+
protected setDragStartPoints(list: ILeafList | ILeaf[]): void;
|
|
40
43
|
protected getDragableList(path: ILeafList): void;
|
|
41
44
|
protected drag(data: IPointerEvent): void;
|
|
42
45
|
protected dragReal(): void;
|
|
@@ -69,6 +72,7 @@ declare class InteractionBase implements IInteraction {
|
|
|
69
72
|
config: IInteractionConfig;
|
|
70
73
|
cursor: ICursorType | ICursorType[];
|
|
71
74
|
get hitRadius(): number;
|
|
75
|
+
bottomList?: IPickBottom[];
|
|
72
76
|
shrinkCanvasBounds: IBounds;
|
|
73
77
|
downData: IPointerEvent;
|
|
74
78
|
hoverData: IPointerEvent;
|