@leafer-ui/event 1.9.0 → 1.9.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/event",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "@leafer-ui/event",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.9.0"
25
+ "@leafer/core": "1.9.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.9.0"
28
+ "@leafer/interface": "1.9.2"
29
29
  }
30
30
  }
package/src/DragEvent.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IDragEvent, IPointData, ILeaf, ILeafList, IObject, IBoundsData } from '@leafer/interface'
2
2
  import { registerUIEvent, LeafList, BoundsHelper, PointHelper } from '@leafer/core'
3
+ import { DragBoundsHelper } from '@leafer-ui/draw'
3
4
 
4
5
  import { PointerEvent } from './PointerEvent'
5
6
 
@@ -40,36 +41,13 @@ export class DragEvent extends PointerEvent implements IDragEvent {
40
41
  static getValidMove(leaf: ILeaf, start: IPointData, total: IPointData, checkLimit = true): IPointData {
41
42
  const move = leaf.getLocalPoint(total, null, true)
42
43
  PointHelper.move(move, start.x - leaf.x, start.y - leaf.y)
43
- if (checkLimit) this.limitMove(leaf, move) // 检查拖拽限制
44
+ if (checkLimit) this.limitMove(leaf, move)
45
+ DragBoundsHelper.axisMove(leaf, move)
44
46
  return move
45
47
  }
46
48
 
47
49
  static limitMove(leaf: ILeaf, move: IPointData): void {
48
- const { draggable, dragBounds } = leaf
49
- if (dragBounds) this.getMoveInDragBounds(leaf.__localBoxBounds, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true)
50
- if (draggable === 'x') move.y = 0
51
- if (draggable === 'y') move.x = 0
52
- }
53
-
54
- static getMoveInDragBounds(childBox: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData {
55
- const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height
56
- const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height
57
-
58
- if (!change) move = { ...move }
59
-
60
- if (BoundsHelper.includes(childBox, dragBounds)) { // childBox > dragBounds
61
- if (x > dragBounds.x) move.x += dragBounds.x - x
62
- else if (right < boundsRight) move.x += boundsRight - right
63
- if (y > dragBounds.y) move.y += dragBounds.y - y
64
- else if (bottom < boundsBottom) move.y += boundsBottom - bottom
65
- } else {
66
- if (x < dragBounds.x) move.x += dragBounds.x - x
67
- else if (right > boundsRight) move.x += boundsRight - right
68
- if (y < dragBounds.y) move.y += dragBounds.y - y
69
- else if (bottom > boundsBottom) move.y += boundsBottom - bottom
70
- }
71
-
72
- return move
50
+ DragBoundsHelper.limitMove(leaf, move)
73
51
  }
74
52
 
75
53
  public getPageMove(total?: boolean): IPointData {
package/types/index.d.ts CHANGED
@@ -81,7 +81,6 @@ declare class DragEvent extends PointerEvent implements IDragEvent {
81
81
  static setData(data: IObject): void;
82
82
  static getValidMove(leaf: ILeaf, start: IPointData, total: IPointData, checkLimit?: boolean): IPointData;
83
83
  static limitMove(leaf: ILeaf, move: IPointData): void;
84
- static getMoveInDragBounds(childBox: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData;
85
84
  getPageMove(total?: boolean): IPointData;
86
85
  getInnerMove(relative?: ILeaf, total?: boolean): IPointData;
87
86
  getLocalMove(relative?: ILeaf, total?: boolean): IPointData;