@leafer-ui/interaction-web 1.0.0 → 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-web",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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.0.0",
26
- "@leafer-ui/core": "1.0.0"
25
+ "@leafer/core": "1.0.2",
26
+ "@leafer-ui/core": "1.0.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0"
29
+ "@leafer/interface": "1.0.2"
30
30
  }
31
31
  }
@@ -14,7 +14,7 @@ interface IGestureEvent extends IClientPointData, UIEvent {
14
14
  }
15
15
 
16
16
 
17
- const { getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper
17
+ const { getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag } = InteractionHelper
18
18
 
19
19
  export class Interaction extends InteractionBase {
20
20
 
@@ -146,20 +146,20 @@ export class Interaction extends InteractionBase {
146
146
  protected onPointerDown(e: PointerEvent): void {
147
147
  this.preventDefaultPointer(e)
148
148
 
149
+ if (this.config.pointer.touch || this.useMultiTouch) return
149
150
  this.usePointer || (this.usePointer = true)
150
- if (this.useMultiTouch) return
151
151
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)))
152
152
  }
153
153
 
154
154
  protected onPointerMove(e: PointerEvent): void {
155
+ if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e)) return
155
156
  this.usePointer || (this.usePointer = true)
156
- if (this.useMultiTouch || this.preventWindowPointer(e)) return
157
157
  this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)))
158
158
  }
159
159
 
160
160
  protected onPointerUp(e: PointerEvent): void {
161
161
  if (this.downData) this.preventDefaultPointer(e)
162
- if (this.useMultiTouch || this.preventWindowPointer(e)) return
162
+ if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e)) return
163
163
  this.pointerUp(PointerEventHelper.convert(e, this.getLocal(e)))
164
164
  }
165
165
 
@@ -196,7 +196,10 @@ export class Interaction extends InteractionBase {
196
196
 
197
197
  // touch
198
198
  protected onTouchStart(e: TouchEvent): void {
199
- e.preventDefault()
199
+ const touch = PointerEventHelper.getTouch(e)
200
+ const local = this.getLocal(touch, true)
201
+ const { preventDefault } = this.config.touch
202
+ if (preventDefault === true || (preventDefault === 'auto' && pathCanDrag(this.findPath(local)))) e.preventDefault()
200
203
 
201
204
  this.multiTouchStart(e)
202
205
 
@@ -206,8 +209,7 @@ export class Interaction extends InteractionBase {
206
209
  this.touchTimer = 0
207
210
  }
208
211
  this.useTouch = true
209
- const touch = PointerEventHelper.getTouch(e)
210
- this.pointerDown(PointerEventHelper.convertTouch(e, this.getLocal(touch, true)))
212
+ this.pointerDown(PointerEventHelper.convertTouch(e, local))
211
213
  }
212
214
 
213
215
  protected onTouchMove(e: TouchEvent): void {
@@ -238,7 +240,7 @@ export class Interaction extends InteractionBase {
238
240
 
239
241
  // multiTouch
240
242
  protected multiTouchStart(e: TouchEvent): void {
241
- this.useMultiTouch = (e.touches.length >= 2)
243
+ this.useMultiTouch = (e.touches.length > 1)
242
244
  this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined
243
245
  if (this.useMultiTouch) this.pointerCancel()
244
246
  }
@@ -48,6 +48,7 @@ export const PointerEventHelper = {
48
48
  width: 1,
49
49
  height: 1,
50
50
  pointerType: 'touch',
51
+ multiTouch: e.touches.length > 1,
51
52
  pressure: touch.force,
52
53
  }
53
54
  },