@leafer-ui/interaction 1.0.2 → 1.0.3

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.2",
3
+ "version": "1.0.3",
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.2",
26
- "@leafer-ui/draw": "1.0.2",
27
- "@leafer-ui/event": "1.0.2"
25
+ "@leafer/core": "1.0.3",
26
+ "@leafer-ui/draw": "1.0.3",
27
+ "@leafer-ui/event": "1.0.3"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.0.2",
31
- "@leafer-ui/interface": "1.0.2"
30
+ "@leafer/interface": "1.0.3",
31
+ "@leafer-ui/interface": "1.0.3"
32
32
  }
33
33
  }
@@ -52,6 +52,7 @@ export class InteractionBase implements IInteraction {
52
52
  protected enterPath: LeafList
53
53
 
54
54
  protected waitMenuTap: boolean
55
+ protected waitRightTap: boolean
55
56
  protected waitTap: boolean
56
57
  protected longPressTimer: ITimer
57
58
  protected longPressed: boolean
@@ -110,7 +111,7 @@ export class InteractionBase implements IInteraction {
110
111
  this.longPressWait(data)
111
112
  }
112
113
 
113
- this.waitMenuTap = PointerButton.right(data)
114
+ this.waitRightTap = PointerButton.right(data)
114
115
 
115
116
  this.dragger.setDragData(data) // must after down event
116
117
  if (!this.isHoldRightKey) this.updateCursor(data)
@@ -138,7 +139,7 @@ export class InteractionBase implements IInteraction {
138
139
  const canDrag = PointHelper.getDistance(this.downData, data) > dragDistance
139
140
  if (canDrag) {
140
141
  if (this.waitTap) this.pointerWaitCancel()
141
- this.waitMenuTap = false
142
+ this.waitRightTap = false
142
143
  }
143
144
 
144
145
  this.dragger.checkDrag(data, canDrag)
@@ -207,14 +208,18 @@ export class InteractionBase implements IInteraction {
207
208
  }
208
209
 
209
210
  // context menu
210
-
211
211
  public menu(data: IPointerEvent): void {
212
212
  this.findPath(data)
213
213
  this.emit(PointerEvent.MENU, data)
214
+ this.waitMenuTap = true
215
+ if (!this.downData && this.waitRightTap) this.menuTap(data) // fix: Windows 触摸屏双击右键菜单事件会在pointer.up之后触发
214
216
  }
215
217
 
216
218
  public menuTap(data: IPointerEvent): void {
217
- if (this.waitMenuTap) this.emit(PointerEvent.MENU_TAP, data)
219
+ if (this.waitRightTap && this.waitMenuTap) {
220
+ this.emit(PointerEvent.MENU_TAP, data)
221
+ this.waitRightTap = this.waitMenuTap = false
222
+ }
218
223
  }
219
224
 
220
225
  // window transform
package/src/emit.ts CHANGED
@@ -54,7 +54,7 @@ function emitEvent(leaf: ILeaf, type: string, data: IUIEvent, capture?: boolean,
54
54
  if (leaf.destroyed) return false
55
55
  if (leaf.__.hitSelf && !exclude(leaf, excludePath)) {
56
56
 
57
- if (State.updateEventStyle) State.updateEventStyle(leaf, type) // hoverStyle / pressStyle
57
+ if (State.updateEventStyle && !capture) State.updateEventStyle(leaf, type) // hoverStyle / pressStyle
58
58
 
59
59
  if (leaf.hasEvent(type, capture)) {
60
60
  data.phase = capture ? 1 : ((leaf === data.target) ? 2 : 3)
package/types/index.d.ts CHANGED
@@ -84,6 +84,7 @@ declare class InteractionBase implements IInteraction {
84
84
  protected overPath: LeafList;
85
85
  protected enterPath: LeafList;
86
86
  protected waitMenuTap: boolean;
87
+ protected waitRightTap: boolean;
87
88
  protected waitTap: boolean;
88
89
  protected longPressTimer: ITimer;
89
90
  protected longPressed: boolean;