@leafer-ui/interaction 1.0.1 → 1.0.2
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/Interaction.ts +5 -5
- package/src/InteractionHelper.ts +10 -2
- package/src/config.ts +3 -0
- package/types/index.d.ts +2 -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.2",
|
|
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.2",
|
|
26
|
+
"@leafer-ui/draw": "1.0.2",
|
|
27
|
+
"@leafer-ui/event": "1.0.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.
|
|
31
|
-
"@leafer-ui/interface": "1.0.
|
|
30
|
+
"@leafer/interface": "1.0.2",
|
|
31
|
+
"@leafer-ui/interface": "1.0.2"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Interaction.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { MultiTouchHelper } from './MultiTouchHelper'
|
|
|
12
12
|
import { config } from './config'
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper
|
|
15
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper
|
|
16
16
|
export class InteractionBase implements IInteraction {
|
|
17
17
|
|
|
18
18
|
public target: ILeaf
|
|
@@ -24,7 +24,7 @@ export class InteractionBase implements IInteraction {
|
|
|
24
24
|
public get dragging(): boolean { return this.dragger.dragging }
|
|
25
25
|
public get transforming(): boolean { return this.transformer.transforming }
|
|
26
26
|
|
|
27
|
-
public get moveMode(): boolean { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty }
|
|
27
|
+
public get moveMode(): boolean { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty }
|
|
28
28
|
public get canHover(): boolean { return this.config.pointer.hover && !(this.config as ILeaferConfig).mobile }
|
|
29
29
|
|
|
30
30
|
public get isDragEmpty(): boolean { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)) }
|
|
@@ -33,7 +33,7 @@ export class InteractionBase implements IInteraction {
|
|
|
33
33
|
public get isHoldRightKey(): boolean { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData) }
|
|
34
34
|
public get isHoldSpaceKey(): boolean { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey() }
|
|
35
35
|
|
|
36
|
-
public config: IInteractionConfig = config
|
|
36
|
+
public config: IInteractionConfig = DataHelper.clone(config)
|
|
37
37
|
|
|
38
38
|
public cursor: ICursorType | ICursorType[]
|
|
39
39
|
public get hitRadius(): number { return this.config.pointer.hitRadius }
|
|
@@ -374,11 +374,11 @@ export class InteractionBase implements IInteraction {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
protected checkPath(data: IPointerEvent, useDefaultPath?: boolean): void {
|
|
377
|
-
if (useDefaultPath || this.
|
|
377
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path))) data.path = this.defaultPath
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
public canMove(data: IPointerEvent): boolean { // moveMode and path can move
|
|
381
|
-
return this.moveMode
|
|
381
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path)
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
|
package/src/InteractionHelper.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IEvent, IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IDragEvent, ISwipeEvent, IUIEvent, IPointData, ILeafList, IDropEvent, IObject } from '@leafer/interface'
|
|
2
2
|
import { PointHelper, LeafList } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { SwipeEvent } from '@leafer-ui/event'
|
|
4
|
+
import { SwipeEvent, DragEvent } from '@leafer-ui/event'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const InteractionHelper = {
|
|
@@ -105,7 +105,15 @@ export const InteractionHelper = {
|
|
|
105
105
|
if (list[i].hasEvent(type)) find.add(list[i])
|
|
106
106
|
}
|
|
107
107
|
return find
|
|
108
|
-
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
pathCanDrag(path: ILeafList): boolean {
|
|
111
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(DragEvent.DRAG)))
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
pathHasOutside(path: ILeafList): boolean { // 滚动条元素
|
|
115
|
+
return path && path.list.some(item => item.isOutside)
|
|
116
|
+
},
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
const I = InteractionHelper
|
package/src/config.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ declare const InteractionHelper: {
|
|
|
158
158
|
getBase(e: IObject): IUIEvent;
|
|
159
159
|
pathHasEventType(path: ILeafList, type: string): boolean;
|
|
160
160
|
filterPathByEventType(path: ILeafList, type: string): ILeafList;
|
|
161
|
+
pathCanDrag(path: ILeafList): boolean;
|
|
162
|
+
pathHasOutside(path: ILeafList): boolean;
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
declare const MultiTouchHelper: {
|