@leafer-ui/interaction 1.0.7 → 1.0.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/interaction",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
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.7",
26
- "@leafer-ui/draw": "1.0.7",
27
- "@leafer-ui/event": "1.0.7"
25
+ "@leafer/core": "1.0.9",
26
+ "@leafer-ui/draw": "1.0.9",
27
+ "@leafer-ui/event": "1.0.9"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.0.7",
31
- "@leafer-ui/interface": "1.0.7"
30
+ "@leafer/interface": "1.0.9",
31
+ "@leafer-ui/interface": "1.0.9"
32
32
  }
33
33
  }
package/src/Dragger.ts CHANGED
@@ -137,10 +137,7 @@ export class Dragger {
137
137
  interaction.emit(DragEvent.OUT, data, dragOverPath)
138
138
  interaction.emit(DragEvent.OVER, data, path)
139
139
  }
140
- } else {
141
- interaction.emit(DragEvent.OVER, data, path)
142
- }
143
-
140
+ } else interaction.emit(DragEvent.OVER, data, path)
144
141
  }
145
142
 
146
143
  public dragEnterOrLeave(data: IPointerEvent): void {
@@ -165,9 +162,7 @@ export class Dragger {
165
162
  this.drag(data)
166
163
  this.animate(() => { this.dragEnd(data, 1) })
167
164
 
168
- } else {
169
- this.dragEndReal(data)
170
- }
165
+ } else this.dragEndReal(data)
171
166
  }
172
167
 
173
168
  protected dragEndReal(data?: IPointerEvent): void {
@@ -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, ILeaferConfig } 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, IMoveConfig, IPointerConfig } 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'
@@ -24,19 +24,21 @@ 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 === true || 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 }
27
+ public get moveMode(): boolean { return this.m.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty }
28
+ public get canHover(): boolean { return this.p.hover && !(this.config as ILeaferConfig).mobile }
29
29
 
30
- public get isDragEmpty(): boolean { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)) }
31
- public get isMobileDragEmpty(): boolean { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData) }
32
- public get isHoldMiddleKey(): boolean { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData) }
33
- public get isHoldRightKey(): boolean { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData) }
34
- public get isHoldSpaceKey(): boolean { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey() }
30
+ public get isDragEmpty(): boolean { return this.m.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)) }
31
+ public get isMobileDragEmpty(): boolean { return this.m.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData) }
32
+ public get isHoldMiddleKey(): boolean { return this.m.holdMiddleKey && this.downData && PointerButton.middle(this.downData) }
33
+ public get isHoldRightKey(): boolean { return this.m.holdRightKey && this.downData && PointerButton.right(this.downData) }
34
+ public get isHoldSpaceKey(): boolean { return this.m.holdSpaceKey && Keyboard.isHoldSpaceKey() }
35
35
 
36
36
  public config: IInteractionConfig = DataHelper.clone(config)
37
+ protected get m(): IMoveConfig { return this.config.move }
38
+ protected get p(): IPointerConfig { return this.config.pointer }
37
39
 
38
40
  public cursor: ICursorType | ICursorType[]
39
- public get hitRadius(): number { return this.config.pointer.hitRadius }
41
+ public get hitRadius(): number { return this.p.hitRadius }
40
42
 
41
43
  public bottomList?: IPickBottom[]
42
44
 
@@ -132,7 +134,7 @@ export class InteractionBase implements IInteraction {
132
134
  }
133
135
 
134
136
  public pointerMoveReal(data: IPointerEvent): void {
135
- const { dragHover, dragDistance } = this.config.pointer
137
+ const { dragHover, dragDistance } = this.p
136
138
  this.emit(PointerEvent.BEFORE_MOVE, data, this.defaultPath)
137
139
 
138
140
  if (this.downData) {
@@ -361,7 +363,7 @@ export class InteractionBase implements IInteraction {
361
363
 
362
364
  // update
363
365
  public findPath(data: IPointerEvent, options?: IPickOptions): ILeafList {
364
- const { hitRadius, through } = this.config.pointer
366
+ const { hitRadius, through } = this.p
365
367
  const { bottomList } = this
366
368
  const find = this.selector.getByPoint(data, hitRadius, { bottomList, name: data.type, ...(options || { through }) })
367
369
  if (find.throughPath) data.throughPath = find.throughPath
@@ -384,7 +386,7 @@ export class InteractionBase implements IInteraction {
384
386
  }
385
387
 
386
388
  public canMove(data: IPointerEvent): boolean { // moveMode and path can move
387
- return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path)
389
+ return data && (this.moveMode || (this.m.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path)
388
390
  }
389
391
 
390
392
 
@@ -497,7 +499,7 @@ export class InteractionBase implements IInteraction {
497
499
  this.longPressTimer = setTimeout(() => {
498
500
  this.longPressed = true
499
501
  this.emit(PointerEvent.LONG_PRESS, data)
500
- }, this.config.pointer.longPressTime)
502
+ }, this.p.longPressTime)
501
503
  }
502
504
 
503
505
  protected longTap(data: IPointerEvent): boolean {
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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, IClientPointData, IPointData, IEvent, IObject, IDropEvent, ISwipeEvent, IMultiTouchData, ICursorTypeMap } from '@leafer/interface';
1
+ import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent, ILeafList, IPointDataMap, IFunction, ILeaf, IInteraction, IInteractionCanvas, ISelector, IInteractionConfig, IMoveConfig, IPointerConfig, ICursorType, IPickBottom, IBounds, IEventListenerId, IBooleanMap, IUIEvent, IKeepTouchData, IKeyEvent, IPickOptions, IClientPointData, IPointData, IEvent, IObject, IDropEvent, ISwipeEvent, IMultiTouchData, ICursorTypeMap } from '@leafer/interface';
2
2
  import { LeafList } from '@leafer/core';
3
3
 
4
4
  declare class Transformer {
@@ -73,6 +73,8 @@ declare class InteractionBase implements IInteraction {
73
73
  get isHoldRightKey(): boolean;
74
74
  get isHoldSpaceKey(): boolean;
75
75
  config: IInteractionConfig;
76
+ protected get m(): IMoveConfig;
77
+ protected get p(): IPointerConfig;
76
78
  cursor: ICursorType | ICursorType[];
77
79
  get hitRadius(): number;
78
80
  bottomList?: IPickBottom[];