@leafer-in/editor 1.9.10 → 1.9.11
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 +25 -23
- package/dist/editor.esm.js +25 -23
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +25 -23
- 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 +6 -6
- package/src/display/EditBox.ts +30 -24
- package/types/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.11",
|
|
4
4
|
"description": "@leafer-in/editor",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^1.9.
|
|
38
|
-
"@leafer-ui/core": "^1.9.
|
|
39
|
-
"@leafer-in/resize": "^1.9.
|
|
40
|
-
"@leafer-ui/interface": "^1.9.
|
|
41
|
-
"@leafer-in/interface": "^1.9.
|
|
37
|
+
"@leafer-ui/draw": "^1.9.11",
|
|
38
|
+
"@leafer-ui/core": "^1.9.11",
|
|
39
|
+
"@leafer-in/resize": "^1.9.11",
|
|
40
|
+
"@leafer-ui/interface": "^1.9.11",
|
|
41
|
+
"@leafer-in/interface": "^1.9.11"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/display/EditBox.ts
CHANGED
|
@@ -62,7 +62,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
62
62
|
public get flippedY(): boolean { return this.scaleY < 0 }
|
|
63
63
|
public get flippedOne(): boolean { return this.scaleX * this.scaleY < 0 }
|
|
64
64
|
|
|
65
|
-
public get canUse(): boolean { return
|
|
65
|
+
public get canUse(): boolean { return this.app && this.editor.editing } // 编辑框是否处于激活状态
|
|
66
66
|
public get canGesture(): boolean { // 是否支持手势
|
|
67
67
|
if (!this.canUse) return false
|
|
68
68
|
const { moveable, resizeable, rotateable } = this.mergeConfig
|
|
@@ -148,6 +148,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
148
148
|
updateMoveCursor(this)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// 必须来自 editor.update(),需同步更新编辑工具
|
|
151
152
|
public update(): void {
|
|
152
153
|
const { editor } = this
|
|
153
154
|
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = this.target.getLayoutBounds('box', editor, true)
|
|
@@ -329,29 +330,25 @@ export class EditBox extends Group implements IEditBox {
|
|
|
329
330
|
// 操作事件共用
|
|
330
331
|
|
|
331
332
|
public onTransformStart(e: IUIEvent): void {
|
|
332
|
-
if (this.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
dragStartData.rotation = target.rotation // 用于旋转
|
|
343
|
-
}
|
|
333
|
+
if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1 // move
|
|
334
|
+
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys // 记录正在resize中的元素列表
|
|
335
|
+
|
|
336
|
+
const { dragStartData, target } = this
|
|
337
|
+
dragStartData.x = e.x
|
|
338
|
+
dragStartData.y = e.y
|
|
339
|
+
dragStartData.totalOffset = getPointData() // 缩放、旋转造成的总偏移量,一般用于手势操作的move纠正
|
|
340
|
+
dragStartData.point = { x: target.x, y: target.y } // 用于移动
|
|
341
|
+
dragStartData.bounds = { ...target.getLayoutBounds('box', 'local') } // 用于resize
|
|
342
|
+
dragStartData.rotation = target.rotation // 用于旋转
|
|
344
343
|
}
|
|
345
344
|
|
|
346
345
|
public onTransformEnd(e: IUIEvent): void {
|
|
347
|
-
if (this.
|
|
348
|
-
|
|
349
|
-
if (this.resizing) ResizeEvent.resizingKeys = null
|
|
346
|
+
if (this.canDragLimitAnimate && (e instanceof DragEvent || e instanceof MoveEvent)) this.transformTool.onMove(e)
|
|
347
|
+
if (this.resizing) ResizeEvent.resizingKeys = null
|
|
350
348
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
349
|
+
this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false
|
|
350
|
+
this.editor.opacity = 1
|
|
351
|
+
this.editor.update() // 移动端手势操作hideOnMove移动需强制更新一次
|
|
355
352
|
}
|
|
356
353
|
|
|
357
354
|
// 手势控制元素
|
|
@@ -386,6 +383,14 @@ export class EditBox extends Group implements IEditBox {
|
|
|
386
383
|
}
|
|
387
384
|
}
|
|
388
385
|
|
|
386
|
+
public onGestureStart(e: IUIEvent): void {
|
|
387
|
+
if (this.canGesture && (e as MoveEvent).moveType !== 'drag') this.onTransformStart(e)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public onGestureEnd(e: IUIEvent): void {
|
|
391
|
+
if (this.canGesture && (e as MoveEvent).moveType !== 'drag') this.onTransformEnd(e)
|
|
392
|
+
}
|
|
393
|
+
|
|
389
394
|
// 键盘
|
|
390
395
|
|
|
391
396
|
public isHoldRotateKey(e: IUIEvent): boolean { // 按住ctrl在控制点上变旋转功能
|
|
@@ -482,11 +487,12 @@ export class EditBox extends Group implements IEditBox {
|
|
|
482
487
|
[[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
|
|
483
488
|
[KeyEvent.DOWN, this.onArrow, this],
|
|
484
489
|
|
|
485
|
-
[
|
|
486
|
-
[
|
|
487
|
-
[
|
|
490
|
+
[MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
491
|
+
[ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
492
|
+
[RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
488
493
|
|
|
489
|
-
[[MoveEvent.
|
|
494
|
+
[[MoveEvent.START, ZoomEvent.START, RotateEvent.START], this.onGestureStart, this],
|
|
495
|
+
[[MoveEvent.END, ZoomEvent.END, RotateEvent.END], this.onGestureEnd, this],
|
|
490
496
|
])
|
|
491
497
|
)
|
|
492
498
|
})
|
package/types/index.d.ts
CHANGED
|
@@ -190,6 +190,8 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
190
190
|
onMove(e: MoveEvent): void;
|
|
191
191
|
onScale(e: ZoomEvent): void;
|
|
192
192
|
onRotate(e: RotateEvent): void;
|
|
193
|
+
onGestureStart(e: IUIEvent): void;
|
|
194
|
+
onGestureEnd(e: IUIEvent): void;
|
|
193
195
|
isHoldRotateKey(e: IUIEvent): boolean;
|
|
194
196
|
protected onKey(e: KeyEvent): void;
|
|
195
197
|
onArrow(e: IKeyEvent): void;
|