@leafer-ui/interaction 1.0.4 → 1.0.5

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.4",
3
+ "version": "1.0.5",
4
4
  "description": "@leafer-ui/interaction",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -13,21 +13,21 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/leaferjs/ui.git"
16
+ "url": "https://github.com/leaferjs/leafer-ui.git"
17
17
  },
18
- "homepage": "https://github.com/leaferjs/ui/tree/main/packages/interaction/interaction",
19
- "bugs": "https://github.com/leaferjs/ui/issues",
18
+ "homepage": "https://github.com/leaferjs/leafer-ui/tree/main/packages/interaction/interaction",
19
+ "bugs": "https://github.com/leaferjs/leafer-ui/issues",
20
20
  "keywords": [
21
21
  "leafer-ui",
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.4",
26
- "@leafer-ui/draw": "1.0.4",
27
- "@leafer-ui/event": "1.0.4"
25
+ "@leafer/core": "1.0.5",
26
+ "@leafer-ui/draw": "1.0.5",
27
+ "@leafer-ui/event": "1.0.5"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.0.4",
31
- "@leafer-ui/interface": "1.0.4"
30
+ "@leafer/interface": "1.0.5",
31
+ "@leafer-ui/interface": "1.0.5"
32
32
  }
33
33
  }
package/src/Dragger.ts CHANGED
@@ -20,8 +20,8 @@ export class Dragger {
20
20
  public dragData: IDragEvent
21
21
  protected downData: IPointerEvent
22
22
 
23
- public dragableList: ILeafList
24
- public realDragableList: ILeafList
23
+ public draggableList: ILeafList
24
+ public realDraggableList: ILeafList
25
25
  protected dragOverPath: ILeafList
26
26
  protected dragEnterPath: ILeafList
27
27
 
@@ -43,9 +43,10 @@ export class Dragger {
43
43
  this.canAnimate = this.canDragOut = true
44
44
  }
45
45
 
46
- public getList(): ILeafList {
46
+ public getList(realDraggable?: boolean, hover?: boolean): ILeafList {
47
47
  const { proxy } = this.interaction.selector
48
- return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList
48
+ const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList
49
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList) // realDraggable 需排除代理选择器,它有自身的拖拽逻辑
49
50
  }
50
51
 
51
52
  public checkDrag(data: IPointerEvent, canDrag: boolean): void {
@@ -76,8 +77,8 @@ export class Dragger {
76
77
  this.dragging = canDrag && PointerButton.left(data)
77
78
  if (this.dragging) {
78
79
  this.interaction.emit(DragEvent.START, this.dragData)
79
- this.getDragableList(this.dragData.path)
80
- this.setDragStartPoints(this.realDragableList = this.getList())
80
+ this.getDraggableList(this.dragData.path)
81
+ this.setDragStartPoints(this.realDraggableList = this.getList(true))
81
82
  }
82
83
  }
83
84
  }
@@ -87,12 +88,12 @@ export class Dragger {
87
88
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y })
88
89
  }
89
90
 
90
- protected getDragableList(path: ILeafList): void {
91
+ protected getDraggableList(path: ILeafList): void {
91
92
  let leaf: ILeaf
92
93
  for (let i = 0, len = path.length; i < len; i++) {
93
94
  leaf = path.list[i]
94
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
95
- this.dragableList = new LeafList(leaf)
95
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
96
+ this.draggableList = new LeafList(leaf)
96
97
  break
97
98
  }
98
99
  }
@@ -118,7 +119,7 @@ export class Dragger {
118
119
 
119
120
  protected dragReal(): void {
120
121
  const { running } = this.interaction
121
- const list = this.realDragableList
122
+ const list = this.realDraggableList
122
123
  if (list.length && running) {
123
124
  const { totalX, totalY } = this.dragData
124
125
  list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })))
@@ -221,7 +222,7 @@ export class Dragger {
221
222
  }
222
223
 
223
224
  protected dragReset(): void {
224
- DragEvent.list = DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null
225
+ DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null
225
226
  }
226
227
 
227
228
 
@@ -201,6 +201,7 @@ export class InteractionBase implements IInteraction {
201
201
 
202
202
 
203
203
  public multiTouch(data: IUIEvent, list: IKeepTouchData[]): void {
204
+ if (this.config.multiTouch.disabled) return
204
205
  const { move, angle, scale, center } = MultiTouchHelper.getData(list)
205
206
  this.rotate(getRotateEventData(center, angle, data))
206
207
  this.zoom(getZoomEventData(center, scale, data))
@@ -425,7 +426,7 @@ export class InteractionBase implements IInteraction {
425
426
  public updateHoverData(data?: IPointerEvent): void {
426
427
  if (!data) data = this.hoverData
427
428
  if (!data) return
428
- this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE })
429
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE })
429
430
  this.hoverData = data
430
431
  }
431
432
 
@@ -448,7 +449,7 @@ export class InteractionBase implements IInteraction {
448
449
  const { path } = data
449
450
  for (let i = 0, len = path.length; i < len; i++) {
450
451
  leaf = path.list[i]
451
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor
452
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor
452
453
  if (cursor) break
453
454
  }
454
455
 
package/src/config.ts CHANGED
@@ -22,6 +22,7 @@ export const config: IInteractionConfig = {
22
22
  touch: {
23
23
  preventDefault: true
24
24
  },
25
+ multiTouch: {},
25
26
  cursor: true,
26
27
  keyEvent: true
27
28
  }
package/types/index.d.ts CHANGED
@@ -26,8 +26,8 @@ declare class Dragger {
26
26
  dragging: boolean;
27
27
  dragData: IDragEvent;
28
28
  protected downData: IPointerEvent;
29
- dragableList: ILeafList;
30
- realDragableList: ILeafList;
29
+ draggableList: ILeafList;
30
+ realDraggableList: ILeafList;
31
31
  protected dragOverPath: ILeafList;
32
32
  protected dragEnterPath: ILeafList;
33
33
  protected dragStartPoints: IPointDataMap;
@@ -37,11 +37,11 @@ declare class Dragger {
37
37
  protected animateWait: IFunction;
38
38
  constructor(interaction: InteractionBase);
39
39
  setDragData(data: IPointerEvent): void;
40
- getList(): ILeafList;
40
+ getList(realDraggable?: boolean, hover?: boolean): ILeafList;
41
41
  checkDrag(data: IPointerEvent, canDrag: boolean): void;
42
42
  dragStart(data: IPointerEvent, canDrag: boolean): void;
43
43
  protected setDragStartPoints(list: ILeafList | ILeaf[]): void;
44
- protected getDragableList(path: ILeafList): void;
44
+ protected getDraggableList(path: ILeafList): void;
45
45
  protected drag(data: IPointerEvent): void;
46
46
  protected dragReal(): void;
47
47
  dragOverOrOut(data: IPointerEvent): void;