@leafer-ui/event 1.0.10 → 1.1.1
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 +3 -3
- package/src/DragEvent.ts +6 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/event",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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.
|
|
25
|
+
"@leafer/core": "1.1.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.
|
|
28
|
+
"@leafer/interface": "1.1.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/DragEvent.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDragEvent, IPointData, ILeaf, ILeafList, IObject, IBoundsData } from '@leafer/interface'
|
|
2
|
-
import { registerUIEvent, LeafList, BoundsHelper } from '@leafer/core'
|
|
2
|
+
import { registerUIEvent, LeafList, BoundsHelper, PointHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { PointerEvent } from './PointerEvent'
|
|
5
5
|
|
|
@@ -38,10 +38,9 @@ export class DragEvent extends PointerEvent implements IDragEvent {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
static getValidMove(leaf: ILeaf, start: IPointData, total: IPointData): IPointData {
|
|
41
|
-
const { draggable, dragBounds
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
move.y += start.y - y
|
|
41
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true)
|
|
42
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y)
|
|
43
|
+
|
|
45
44
|
if (dragBounds) this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true)
|
|
46
45
|
if (draggable === 'x') move.y = 0
|
|
47
46
|
if (draggable === 'y') move.x = 0
|
|
@@ -49,8 +48,7 @@ export class DragEvent extends PointerEvent implements IDragEvent {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
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
|
|
51
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height
|
|
54
52
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height
|
|
55
53
|
|
|
56
54
|
if (!change) move = { ...move }
|
|
@@ -100,9 +98,7 @@ export class DragEvent extends PointerEvent implements IDragEvent {
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
public getPageBounds(): IBoundsData {
|
|
103
|
-
const total = this.getPageTotal()
|
|
104
|
-
const start = this.getPagePoint()
|
|
105
|
-
const bounds = {} as IBoundsData
|
|
101
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {} as IBoundsData
|
|
106
102
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y)
|
|
107
103
|
BoundsHelper.unsign(bounds)
|
|
108
104
|
return bounds
|