@leafer-ui/event 1.0.0-rc.26 → 1.0.0-rc.28

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.0.0-rc.26",
3
+ "version": "1.0.0-rc.28",
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.0.0-rc.26"
25
+ "@leafer/core": "1.0.0-rc.28"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.26"
28
+ "@leafer/interface": "1.0.0-rc.28"
29
29
  }
30
30
  }
package/src/DragEvent.ts CHANGED
@@ -48,15 +48,25 @@ export class DragEvent extends PointerEvent implements IDragEvent {
48
48
  return move
49
49
  }
50
50
 
51
- static getMoveInDragBounds(box: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData {
52
- const x = box.x + move.x, y = box.y + move.y
53
- const right = x + box.width, bottom = y + box.height
51
+ static getMoveInDragBounds(childBox: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData {
52
+ const x = childBox.x + move.x, y = childBox.y + move.y
53
+ const right = x + childBox.width, bottom = y + childBox.height
54
54
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height
55
+
55
56
  if (!change) move = { ...move }
56
- if (x < dragBounds.x) move.x += dragBounds.x - x
57
- else if (right > boundsRight) move.x += boundsRight - right
58
- if (y < dragBounds.y) move.y += dragBounds.y - y
59
- else if (bottom > boundsBottom) move.y += boundsBottom - bottom
57
+
58
+ if (BoundsHelper.includes(childBox, dragBounds)) { // childBox > dragBounds
59
+ if (x > dragBounds.x) move.x += dragBounds.x - x
60
+ else if (right < boundsRight) move.x += boundsRight - right
61
+ if (y > dragBounds.y) move.y += dragBounds.y - y
62
+ else if (bottom < boundsBottom) move.y += boundsBottom - bottom
63
+ } else {
64
+ if (x < dragBounds.x) move.x += dragBounds.x - x
65
+ else if (right > boundsRight) move.x += boundsRight - right
66
+ if (y < dragBounds.y) move.y += dragBounds.y - y
67
+ else if (bottom > boundsBottom) move.y += boundsBottom - bottom
68
+ }
69
+
60
70
  return move
61
71
  }
62
72
 
package/types/index.d.ts CHANGED
@@ -73,7 +73,7 @@ declare class DragEvent extends PointerEvent implements IDragEvent {
73
73
  static setList(data: ILeaf | ILeaf[] | ILeafList): void;
74
74
  static setData(data: IObject): void;
75
75
  static getValidMove(leaf: ILeaf, start: IPointData, total: IPointData): IPointData;
76
- static getMoveInDragBounds(box: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData;
76
+ static getMoveInDragBounds(childBox: IBoundsData, dragBounds: IBoundsData, move: IPointData, change?: boolean): IPointData;
77
77
  getPageMove(total?: boolean): IPointData;
78
78
  getInnerMove(relative?: ILeaf, total?: boolean): IPointData;
79
79
  getLocalMove(relative?: ILeaf, total?: boolean): IPointData;