@leafer-in/editor 1.4.0 → 1.4.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/dist/editor.cjs +24 -7
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +25 -8
- package/dist/editor.esm.js.map +1 -1
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +24 -7
- package/dist/editor.js.map +1 -1
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +5 -5
- package/src/Editor.ts +2 -1
- package/src/editor/simulate.ts +6 -1
- package/src/helper/EditDataHelper.ts +17 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "@leafer-in/editor",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/core": "^1.4.
|
|
38
|
-
"@leafer-in/resize": "^1.4.
|
|
39
|
-
"@leafer-ui/interface": "^1.4.
|
|
40
|
-
"@leafer-in/interface": "^1.4.
|
|
37
|
+
"@leafer-ui/core": "^1.4.2",
|
|
38
|
+
"@leafer-in/resize": "^1.4.2",
|
|
39
|
+
"@leafer-ui/interface": "^1.4.2",
|
|
40
|
+
"@leafer-in/interface": "^1.4.2"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -258,9 +258,10 @@ export class Editor extends Group implements IEditor {
|
|
|
258
258
|
// transform
|
|
259
259
|
|
|
260
260
|
public move(x: number | IPointData, y = 0): void {
|
|
261
|
+
const { element } = this
|
|
261
262
|
if (!this.checkTransform('moveable')) return
|
|
262
263
|
|
|
263
|
-
|
|
264
|
+
|
|
264
265
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? { ...x } : { x, y }, null, true)
|
|
265
266
|
if (this.multiple) element.safeChange(() => element.move(x, y))
|
|
266
267
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y })
|
package/src/editor/simulate.ts
CHANGED
|
@@ -9,6 +9,11 @@ const bounds = new Bounds()
|
|
|
9
9
|
export function simulate(editor: IEditor) {
|
|
10
10
|
const { simulateTarget, list } = editor
|
|
11
11
|
const { zoomLayer } = list[0].leafer.zoomLayer as IGroup // follow zoomLayer zoom / move
|
|
12
|
-
simulateTarget.safeChange(() =>
|
|
12
|
+
simulateTarget.safeChange(() => {
|
|
13
|
+
bounds.setListWithFn(list, (leaf: ILeaf) => leaf.getBounds('box', 'page'))
|
|
14
|
+
if (bounds.width === 0) bounds.width = 0.1 // fix
|
|
15
|
+
if (bounds.height === 0) bounds.height = 0.1
|
|
16
|
+
simulateTarget.reset(bounds.get())
|
|
17
|
+
})
|
|
13
18
|
zoomLayer.add(simulateTarget)
|
|
14
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IBoundsData, IPointData, IAround, IAlign, IUI, ILayoutBoundsData } from '@leafer-ui/interface'
|
|
2
|
-
import { AroundHelper, MathHelper, PointHelper, Direction9 } from '@leafer-ui/draw'
|
|
2
|
+
import { AroundHelper, MathHelper, PointHelper, BoundsHelper, Bounds, Direction9 } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
4
|
import { IEditorScaleEvent, IEditorSkewEvent, IEditorRotateEvent } from '@leafer-in/interface'
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@ export const EditDataHelper = {
|
|
|
13
13
|
getScaleData(element: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMove: IPointData, lockRatio: boolean | 'corner', around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent {
|
|
14
14
|
let align: IAlign, origin = {} as IPointData, scaleX: number = 1, scaleY: number = 1
|
|
15
15
|
|
|
16
|
-
const { boxBounds, widthRange, heightRange } = element
|
|
16
|
+
const { boxBounds, widthRange, heightRange, dragBounds } = element
|
|
17
17
|
const { width, height } = startBounds
|
|
18
18
|
|
|
19
19
|
if (around) {
|
|
@@ -116,6 +116,21 @@ export const EditDataHelper = {
|
|
|
116
116
|
if (scaleY < 0) scaleY = 1 / boxBounds.height / worldTransform.scaleY
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// 检查限制
|
|
120
|
+
|
|
121
|
+
toPoint(around || align, boxBounds, origin, true)
|
|
122
|
+
|
|
123
|
+
if (dragBounds) {
|
|
124
|
+
const allowBounds = dragBounds === 'parent' ? element.parent.boxBounds : dragBounds
|
|
125
|
+
const localBounds = new Bounds(element.__localBoxBounds)
|
|
126
|
+
localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY)
|
|
127
|
+
|
|
128
|
+
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
129
|
+
const realBounds = localBounds.getIntersect(allowBounds)
|
|
130
|
+
scaleX *= realBounds.width / localBounds.width
|
|
131
|
+
scaleY *= realBounds.height / localBounds.height // 后续需优化带旋转的场景
|
|
132
|
+
}
|
|
133
|
+
}
|
|
119
134
|
|
|
120
135
|
if (widthRange) {
|
|
121
136
|
const nowWidth = boxBounds.width * element.scaleX
|
|
@@ -127,9 +142,6 @@ export const EditDataHelper = {
|
|
|
127
142
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight
|
|
128
143
|
}
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
toPoint(around || align, boxBounds, origin, true)
|
|
132
|
-
|
|
133
145
|
return { origin, scaleX, scaleY, direction, lockRatio, around }
|
|
134
146
|
},
|
|
135
147
|
|