@leafer-ui/interaction-web 1.6.7 → 1.8.0

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-web",
3
- "version": "1.6.7",
3
+ "version": "1.8.0",
4
4
  "description": "@leafer-ui/interaction-web",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.6.7",
26
- "@leafer-ui/core": "1.6.7"
25
+ "@leafer/core": "1.8.0",
26
+ "@leafer-ui/core": "1.8.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.6.7"
29
+ "@leafer/interface": "1.8.0"
30
30
  }
31
31
  }
@@ -26,6 +26,10 @@ export class Interaction extends InteractionBase {
26
26
  protected useMultiTouch: boolean
27
27
  protected useTouch: boolean
28
28
 
29
+ protected get notPointer(): boolean { const { p } = this; return p.type !== 'pointer' || p.touch || this.useMultiTouch }
30
+ protected get notTouch(): boolean { const { p } = this; return p.type === 'mouse' || this.usePointer }
31
+ protected get notMouse(): boolean { return this.usePointer || this.useTouch }
32
+
29
33
  protected touchTimer: ITimer
30
34
  protected touches?: Touch[]
31
35
  protected lastGestureScale: number
@@ -146,13 +150,13 @@ export class Interaction extends InteractionBase {
146
150
  protected onPointerDown(e: PointerEvent): void {
147
151
  this.preventDefaultPointer(e)
148
152
 
149
- if (this.config.pointer.touch || this.useMultiTouch) return
153
+ if (this.notPointer) return
150
154
  this.usePointer || (this.usePointer = true)
151
155
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)))
152
156
  }
153
157
 
154
158
  protected onPointerMove(e: PointerEvent, isLeave?: boolean): void {
155
- if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e)) return
159
+ if (this.notPointer || this.preventWindowPointer(e)) return
156
160
  this.usePointer || (this.usePointer = true)
157
161
  const data = PointerEventHelper.convert(e, this.getLocal(e, true))
158
162
  isLeave ? this.pointerHover(data) : this.pointerMove(data)
@@ -164,7 +168,7 @@ export class Interaction extends InteractionBase {
164
168
 
165
169
  protected onPointerUp(e: PointerEvent): void {
166
170
  if (this.downData) this.preventDefaultPointer(e)
167
- if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e)) return
171
+ if (this.notPointer || this.preventWindowPointer(e)) return
168
172
  this.pointerUp(PointerEventHelper.convert(e, this.getLocal(e)))
169
173
  }
170
174
 
@@ -178,23 +182,23 @@ export class Interaction extends InteractionBase {
178
182
  protected onMouseDown(e: MouseEvent): void {
179
183
  this.preventDefaultPointer(e)
180
184
 
181
- if (this.useTouch || this.usePointer) return
185
+ if (this.notMouse) return
182
186
  this.pointerDown(PointerEventHelper.convertMouse(e, this.getLocal(e)))
183
187
  }
184
188
 
185
189
  protected onMouseMove(e: MouseEvent): void {
186
- if (this.useTouch || this.usePointer || this.preventWindowPointer(e)) return
190
+ if (this.notMouse || this.preventWindowPointer(e)) return
187
191
  this.pointerMove(PointerEventHelper.convertMouse(e, this.getLocal(e, true)))
188
192
  }
189
193
 
190
194
  protected onMouseUp(e: MouseEvent): void {
191
195
  if (this.downData) this.preventDefaultPointer(e)
192
- if (this.useTouch || this.usePointer || this.preventWindowPointer(e)) return
196
+ if (this.notMouse || this.preventWindowPointer(e)) return
193
197
  this.pointerUp(PointerEventHelper.convertMouse(e, this.getLocal(e)))
194
198
  }
195
199
 
196
200
  protected onMouseCancel(): void {
197
- if (this.useTouch || this.usePointer) return
201
+ if (this.notMouse) return
198
202
  this.pointerCancel()
199
203
  }
200
204
 
@@ -208,7 +212,7 @@ export class Interaction extends InteractionBase {
208
212
 
209
213
  this.multiTouchStart(e)
210
214
 
211
- if (this.usePointer) return
215
+ if (this.notTouch) return
212
216
  if (this.touchTimer) {
213
217
  window.clearTimeout(this.touchTimer)
214
218
  this.touchTimer = 0
@@ -220,7 +224,7 @@ export class Interaction extends InteractionBase {
220
224
  protected onTouchMove(e: TouchEvent): void {
221
225
  this.multiTouchMove(e)
222
226
 
223
- if (this.usePointer || this.preventWindowPointer(e)) return
227
+ if (this.notTouch || this.preventWindowPointer(e)) return
224
228
  const touch = PointerEventHelper.getTouch(e)
225
229
  this.pointerMove(PointerEventHelper.convertTouch(e, this.getLocal(touch)))
226
230
  }
@@ -228,7 +232,7 @@ export class Interaction extends InteractionBase {
228
232
  protected onTouchEnd(e: TouchEvent): void {
229
233
  this.multiTouchEnd()
230
234
 
231
- if (this.usePointer || this.preventWindowPointer(e)) return
235
+ if (this.notTouch || this.preventWindowPointer(e)) return
232
236
  if (this.touchTimer) clearTimeout(this.touchTimer)
233
237
  this.touchTimer = setTimeout(() => {
234
238
  this.useTouch = false
@@ -238,7 +242,7 @@ export class Interaction extends InteractionBase {
238
242
  }
239
243
 
240
244
  protected onTouchCancel(): void {
241
- if (this.usePointer) return
245
+ if (this.notTouch) return
242
246
  this.pointerCancel()
243
247
  }
244
248
 
package/types/index.d.ts CHANGED
@@ -13,6 +13,9 @@ declare class Interaction extends InteractionBase {
13
13
  protected usePointer: boolean;
14
14
  protected useMultiTouch: boolean;
15
15
  protected useTouch: boolean;
16
+ protected get notPointer(): boolean;
17
+ protected get notTouch(): boolean;
18
+ protected get notMouse(): boolean;
16
19
  protected touchTimer: ITimer;
17
20
  protected touches?: Touch[];
18
21
  protected lastGestureScale: number;