@leafer-ui/interaction 1.0.0 → 1.0.1
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 +9 -4
- package/src/Interaction.ts +8 -4
- package/src/Transformer.ts +3 -0
- package/types/index.d.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interaction",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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.
|
|
26
|
-
"@leafer-ui/draw": "1.0.
|
|
27
|
-
"@leafer-ui/event": "1.0.
|
|
25
|
+
"@leafer/core": "1.0.1",
|
|
26
|
+
"@leafer-ui/draw": "1.0.1",
|
|
27
|
+
"@leafer-ui/event": "1.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.
|
|
31
|
-
"@leafer-ui/interface": "1.0.
|
|
30
|
+
"@leafer/interface": "1.0.1",
|
|
31
|
+
"@leafer-ui/interface": "1.0.1"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Dragger.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointerEvent, IDragEvent, ILeaf, ILeafList, ITimer, IFunction, IPointDataMap } from '@leafer/interface'
|
|
1
|
+
import { IPointerEvent, IDragEvent, ILeaf, ILeafList, ITimer, IFunction, IPointDataMap, IMoveEvent } 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'
|
|
@@ -58,7 +58,10 @@ export class Dragger {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (!this.moving && canDrag) {
|
|
61
|
-
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
|
|
61
|
+
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
|
|
62
|
+
(this.dragData as IMoveEvent).moveType = 'drag'
|
|
63
|
+
interaction.emit(MoveEvent.START, this.dragData)
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
if (!this.moving) {
|
|
@@ -103,6 +106,7 @@ export class Dragger {
|
|
|
103
106
|
this.dragData.path = path
|
|
104
107
|
|
|
105
108
|
if (this.moving) {
|
|
109
|
+
(this.dragData as IMoveEvent).moveType = 'drag'
|
|
106
110
|
interaction.emit(MoveEvent.BEFORE_MOVE, this.dragData)
|
|
107
111
|
interaction.emit(MoveEvent.MOVE, this.dragData)
|
|
108
112
|
} else if (this.dragging) {
|
|
@@ -174,7 +178,8 @@ export class Dragger {
|
|
|
174
178
|
endDragData.path = path
|
|
175
179
|
|
|
176
180
|
if (this.moving) {
|
|
177
|
-
this.moving = false
|
|
181
|
+
this.moving = false;
|
|
182
|
+
(endDragData as IMoveEvent).moveType = 'drag'
|
|
178
183
|
interaction.emit(MoveEvent.END, endDragData)
|
|
179
184
|
}
|
|
180
185
|
|
|
@@ -248,7 +253,7 @@ export class Dragger {
|
|
|
248
253
|
PointHelper.move(downData, moveX, moveY)
|
|
249
254
|
PointHelper.move(this.dragData, moveX, moveY)
|
|
250
255
|
|
|
251
|
-
interaction.move({ ...data, moveX, moveY, totalX, totalY })
|
|
256
|
+
interaction.move({ ...data, moveX, moveY, totalX, totalY, moveType: 'drag' })
|
|
252
257
|
interaction.pointerMoveReal(data)
|
|
253
258
|
}, 10)
|
|
254
259
|
}
|
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, IPickBottom, IClientPointData, IPointData } 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, IClientPointData, IPointData, ILeaferConfig } 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'
|
|
@@ -22,10 +22,13 @@ export class InteractionBase implements IInteraction {
|
|
|
22
22
|
public running: boolean
|
|
23
23
|
|
|
24
24
|
public get dragging(): boolean { return this.dragger.dragging }
|
|
25
|
+
public get transforming(): boolean { return this.transformer.transforming }
|
|
26
|
+
|
|
25
27
|
public get moveMode(): boolean { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty }
|
|
28
|
+
public get canHover(): boolean { return this.config.pointer.hover && !(this.config as ILeaferConfig).mobile }
|
|
26
29
|
|
|
27
30
|
public get isDragEmpty(): boolean { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)) }
|
|
28
|
-
public get isMobileDragEmpty(): boolean { return this.config.move.dragEmpty && !this.
|
|
31
|
+
public get isMobileDragEmpty(): boolean { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData) }
|
|
29
32
|
public get isHoldMiddleKey(): boolean { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData) }
|
|
30
33
|
public get isHoldRightKey(): boolean { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData) }
|
|
31
34
|
public get isHoldSpaceKey(): boolean { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey() }
|
|
@@ -164,6 +167,7 @@ export class InteractionBase implements IInteraction {
|
|
|
164
167
|
if (!downData) return
|
|
165
168
|
|
|
166
169
|
PointerButton.defaultLeft(data)
|
|
170
|
+
data.multiTouch = downData.multiTouch
|
|
167
171
|
|
|
168
172
|
this.findPath(data)
|
|
169
173
|
const upData = { ...data, path: data.path.clone() }
|
|
@@ -265,7 +269,7 @@ export class InteractionBase implements IInteraction {
|
|
|
265
269
|
|
|
266
270
|
// helper
|
|
267
271
|
protected pointerHover(data: IPointerEvent): void {
|
|
268
|
-
if (this.
|
|
272
|
+
if (this.canHover) {
|
|
269
273
|
this.pointerOverOrOut(data)
|
|
270
274
|
this.pointerEnterOrLeave(data)
|
|
271
275
|
}
|
|
@@ -421,7 +425,7 @@ export class InteractionBase implements IInteraction {
|
|
|
421
425
|
}
|
|
422
426
|
|
|
423
427
|
public updateCursor(data?: IPointerEvent): void {
|
|
424
|
-
if (!this.config.cursor || !this.
|
|
428
|
+
if (!this.config.cursor || !this.canHover) return
|
|
425
429
|
|
|
426
430
|
if (!data) {
|
|
427
431
|
this.updateHoverData()
|
package/src/Transformer.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { InteractionBase } from './Interaction'
|
|
|
6
6
|
|
|
7
7
|
export class Transformer {
|
|
8
8
|
|
|
9
|
+
public get transforming(): boolean { return !!(this.moveData || this.zoomData || this.rotateData) }
|
|
10
|
+
|
|
9
11
|
protected interaction: InteractionBase
|
|
10
12
|
protected moveData: IMoveEvent
|
|
11
13
|
protected zoomData: IZoomEvent
|
|
@@ -18,6 +20,7 @@ export class Transformer {
|
|
|
18
20
|
|
|
19
21
|
public move(data: IMoveEvent): void {
|
|
20
22
|
const { interaction } = this
|
|
23
|
+
if (!data.moveType) data.moveType = 'move'
|
|
21
24
|
|
|
22
25
|
if (!this.moveData) {
|
|
23
26
|
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius)
|
package/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent
|
|
|
2
2
|
import { LeafList } from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
declare class Transformer {
|
|
5
|
+
get transforming(): boolean;
|
|
5
6
|
protected interaction: InteractionBase;
|
|
6
7
|
protected moveData: IMoveEvent;
|
|
7
8
|
protected zoomData: IZoomEvent;
|
|
@@ -63,7 +64,9 @@ declare class InteractionBase implements IInteraction {
|
|
|
63
64
|
selector: ISelector;
|
|
64
65
|
running: boolean;
|
|
65
66
|
get dragging(): boolean;
|
|
67
|
+
get transforming(): boolean;
|
|
66
68
|
get moveMode(): boolean;
|
|
69
|
+
get canHover(): boolean;
|
|
67
70
|
get isDragEmpty(): boolean;
|
|
68
71
|
get isMobileDragEmpty(): boolean;
|
|
69
72
|
get isHoldMiddleKey(): boolean;
|