@leafer-ui/interaction 1.5.3 → 1.6.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",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
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.5.3",
26
- "@leafer-ui/draw": "1.5.3",
27
- "@leafer-ui/event": "1.5.3"
25
+ "@leafer/core": "1.6.0",
26
+ "@leafer-ui/draw": "1.6.0",
27
+ "@leafer-ui/event": "1.6.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.5.3",
31
- "@leafer-ui/interface": "1.5.3"
30
+ "@leafer/interface": "1.6.0",
31
+ "@leafer-ui/interface": "1.6.0"
32
32
  }
33
33
  }
@@ -96,8 +96,8 @@ export class InteractionBase implements IInteraction {
96
96
  public pointerDown(data?: IPointerEvent, useDefaultPath?: boolean): void {
97
97
  if (!data) data = this.hoverData
98
98
  if (!data) return
99
- PointerButton.defaultLeft(data)
100
99
 
100
+ PointerButton.defaultLeft(data)
101
101
  this.updateDownData(data)
102
102
  this.checkPath(data, useDefaultPath)
103
103
 
@@ -137,7 +137,7 @@ export class InteractionBase implements IInteraction {
137
137
  if (this.downData) {
138
138
  const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance
139
139
  if (canDrag) {
140
- if (this.waitTap) this.pointerWaitCancel()
140
+ if (this.waitTap || this.longPressTimer) this.pointerWaitCancel()
141
141
  this.waitRightTap = false
142
142
  }
143
143
 
@@ -454,7 +454,9 @@ export class InteractionBase implements IInteraction {
454
454
 
455
455
  public getLocal(clientPoint: IClientPointData, updateClient?: boolean): IPointData {
456
456
  const clientBounds = this.canvas.getClientBounds(updateClient)
457
- return { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y }
457
+ const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y }
458
+ if (this.p.snap) PointHelper.round(point)
459
+ return point
458
460
  }
459
461
 
460
462
 
package/src/config.ts CHANGED
@@ -8,6 +8,7 @@ export const config: IInteractionConfig = {
8
8
  delta: { x: 80 / 4, y: 8.0 }, // 基准速度(会影响zoomSpeed),可根据不同系统、浏览器细化定制
9
9
  },
10
10
  pointer: {
11
+ snap: true,
11
12
  hitRadius: 5,
12
13
  tapTime: 120,
13
14
  longPressTime: 800,