@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/interaction",
3
- "version": "1.0.1",
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.1",
26
- "@leafer-ui/draw": "1.0.1",
27
- "@leafer-ui/event": "1.0.1"
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.1",
31
- "@leafer-ui/interface": "1.0.1"
30
+ "@leafer/interface": "1.0.2",
31
+ "@leafer-ui/interface": "1.0.2"
32
32
  }
33
33
  }
@@ -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.canMove(data)) data.path = this.defaultPath
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 && data && data.path.list.every(item => !item.isOutside)
381
+ return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path)
382
382
  }
383
383
 
384
384
 
@@ -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
@@ -19,6 +19,9 @@ export const config: IInteractionConfig = {
19
19
  swipeDistance: 20,
20
20
  preventDefaultMenu: true
21
21
  },
22
+ touch: {
23
+ preventDefault: true
24
+ },
22
25
  cursor: true,
23
26
  keyEvent: true
24
27
  }
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: {