@leafer-ui/event 1.9.10 → 1.9.12

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.10",
3
+ "version": "1.9.12",
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.10"
25
+ "@leafer/core": "1.9.12"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.9.10"
28
+ "@leafer/interface": "1.9.12"
29
29
  }
30
30
  }
@@ -1,8 +1,8 @@
1
1
  import { IPointData, IBoundsData, IDragBoundsType, ILeaf, ISide } from '@leafer/interface'
2
- import { Bounds, MathHelper, isFinite } from '@leafer/core'
2
+ import { Bounds, BoundsHelper, MathHelper, isFinite } from '@leafer/core'
3
3
 
4
4
 
5
- const { float, sign } = MathHelper, { min, max, abs } = Math
5
+ const { min, max, abs } = Math, { float, sign } = MathHelper, { minX, maxX, minY, maxY } = BoundsHelper
6
6
  const tempContent = new Bounds(), tempDragBounds = new Bounds()
7
7
 
8
8
  export const DragBoundsHelper = {
@@ -74,12 +74,11 @@ export const DragBoundsHelper = {
74
74
  const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale
75
75
  const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale
76
76
 
77
- let correctScaleX: number, correctScaleY: number, aScale: number, bScale: number, aSize: number, bSize: number
77
+ let correctScaleX = 1, correctScaleY = 1, aScale: number, bScale: number, aSize: number, bSize: number
78
78
 
79
79
  if (D.isInnerMode(content, dragBounds, dragBoundsType, 'width')) { // inner 模式
80
80
 
81
- correctScaleX = scale.x < 0 ? 1 / scale.x : 1
82
- if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX, 1) // 阻止镜像
81
+ if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1) // 阻止镜像
83
82
 
84
83
  aSize = float(tempContent.minX - tempDragBounds.minX)
85
84
  bSize = float(tempDragBounds.maxX - tempContent.maxX)
@@ -90,21 +89,23 @@ export const DragBoundsHelper = {
90
89
 
91
90
  } else { // outer 模式
92
91
 
93
- if (scale.x < 0) tempContent.unsign()
92
+ if (scale.x < 0) {
93
+ if (float(minX(content) - minX(dragBounds)) <= 0 || float(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1) // 到达边界时阻止镜像
94
+ tempContent.unsign()
95
+ }
94
96
 
95
97
  aSize = float(tempDragBounds.minX - tempContent.minX)
96
98
  bSize = float(tempContent.maxX - tempDragBounds.maxX)
97
99
 
98
100
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1
99
101
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1
100
- correctScaleX = min(aScale, bScale)
102
+ correctScaleX *= min(aScale, bScale)
101
103
 
102
104
  }
103
105
 
104
106
  if (D.isInnerMode(content, dragBounds, dragBoundsType, 'height')) { // inner 模式
105
107
 
106
- correctScaleY = scale.y < 0 ? 1 / scale.y : 1
107
- if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY) // 阻止镜像
108
+ if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y) // 阻止镜像
108
109
 
109
110
  aSize = float(tempContent.minY - tempDragBounds.minY)
110
111
  bSize = float(tempDragBounds.maxY - tempContent.maxY)
@@ -122,14 +123,17 @@ export const DragBoundsHelper = {
122
123
 
123
124
  } else { // outer 模式
124
125
 
125
- if (scale.y < 0) tempContent.unsign()
126
+ if (scale.y < 0) {
127
+ if (float(minY(content) - minY(dragBounds)) <= 0 || float(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y) // 到达边界时阻止镜像
128
+ tempContent.unsign()
129
+ }
126
130
 
127
131
  aSize = float(tempDragBounds.minY - tempContent.minY)
128
132
  bSize = float(tempContent.maxY - tempDragBounds.maxY)
129
133
 
130
134
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1
131
135
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1
132
- correctScaleY = min(aScale, bScale)
136
+ correctScaleY *= min(aScale, bScale)
133
137
 
134
138
  }
135
139