@leafer-in/editor 1.9.7 → 1.9.9
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 +154 -137
- package/dist/editor.esm.js +156 -139
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +152 -135
- 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/decorator/data.ts +6 -6
- package/src/display/EditBox.ts +52 -43
- package/src/display/EditSelect.ts +5 -5
- package/src/helper/EditDataHelper.ts +76 -69
- package/src/tool/TransformTool.ts +35 -30
- package/types/index.d.ts +7 -6
package/dist/editor.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Event, isArray, defineKey, isNull, isUndefined, isObject, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, isString, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, DragBoundsHelper, Box,
|
|
1
|
+
import { Event, isArray, defineKey, isNull, isUndefined, isObject, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, isString, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, isNumber, DragBoundsHelper, Box, ResizeEvent, getPointData, Text, Matrix, Debug, LeafHelper, PropertyEvent, DataHelper, Plugin, RenderEvent, LeaferEvent, Creator, dataType } from "@leafer-ui/draw";
|
|
2
2
|
|
|
3
|
-
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent,
|
|
3
|
+
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent, useModule } from "@leafer-ui/core";
|
|
4
4
|
|
|
5
5
|
import "@leafer-in/resize";
|
|
6
6
|
|
|
@@ -56,10 +56,6 @@ function targetAttr(fn) {
|
|
|
56
56
|
if (t.config) {
|
|
57
57
|
const isSelect = key === "target";
|
|
58
58
|
if (isSelect) {
|
|
59
|
-
t.setDimOthers(false);
|
|
60
|
-
t.setBright(false);
|
|
61
|
-
if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
|
|
62
|
-
if (t.single) t.element.syncEventer = null;
|
|
63
59
|
const {beforeSelect: beforeSelect} = t.config;
|
|
64
60
|
if (beforeSelect) {
|
|
65
61
|
const check = beforeSelect({
|
|
@@ -67,6 +63,10 @@ function targetAttr(fn) {
|
|
|
67
63
|
});
|
|
68
64
|
if (isObject(check)) value = check; else if (check === false) return;
|
|
69
65
|
}
|
|
66
|
+
t.setDimOthers(false);
|
|
67
|
+
t.setBright(false);
|
|
68
|
+
if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
|
|
69
|
+
if (t.single) t.element.syncEventer = null;
|
|
70
70
|
}
|
|
71
71
|
const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
|
|
72
72
|
if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
|
|
@@ -252,11 +252,12 @@ class EditSelect extends Group {
|
|
|
252
252
|
return !!this.originList;
|
|
253
253
|
}
|
|
254
254
|
get running() {
|
|
255
|
-
const {editor: editor} = this;
|
|
256
|
-
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector &&
|
|
255
|
+
const {editor: editor, app: app} = this;
|
|
256
|
+
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && (app && app.mode === "normal");
|
|
257
257
|
}
|
|
258
258
|
get isMoveMode() {
|
|
259
|
-
|
|
259
|
+
const {app: app} = this;
|
|
260
|
+
return app && app.interaction.moveMode;
|
|
260
261
|
}
|
|
261
262
|
constructor(editor) {
|
|
262
263
|
super();
|
|
@@ -319,12 +320,12 @@ class EditSelect extends Group {
|
|
|
319
320
|
onTap(e) {
|
|
320
321
|
if (e.multiTouch) return;
|
|
321
322
|
const {editor: editor} = this;
|
|
322
|
-
const {select: select} = editor.mergeConfig;
|
|
323
|
+
const {select: select, selectKeep: selectKeep} = editor.mergeConfig;
|
|
323
324
|
if (select === "tap") this.checkAndSelect(e); else if (this.waitSelect) this.waitSelect();
|
|
324
325
|
if (this.needRemoveItem) {
|
|
325
326
|
editor.removeItem(this.needRemoveItem);
|
|
326
327
|
} else if (this.isMoveMode) {
|
|
327
|
-
editor.target = null;
|
|
328
|
+
if (!selectKeep) editor.target = null;
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
checkAndSelect(e) {
|
|
@@ -339,7 +340,7 @@ class EditSelect extends Group {
|
|
|
339
340
|
editor.target = find;
|
|
340
341
|
}
|
|
341
342
|
} else if (this.allow(e.target)) {
|
|
342
|
-
if (!this.isHoldMultipleSelectKey(e)) editor.target = null;
|
|
343
|
+
if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
}
|
|
@@ -458,91 +459,95 @@ const {toPoint: toPoint} = AroundHelper;
|
|
|
458
459
|
const {within: within, sign: sign} = MathHelper;
|
|
459
460
|
|
|
460
461
|
const EditDataHelper = {
|
|
461
|
-
getScaleData(target, startBounds, direction,
|
|
462
|
+
getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
|
|
462
463
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
463
464
|
const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
|
|
464
465
|
const {width: width, height: height} = startBounds;
|
|
465
|
-
if (around) {
|
|
466
|
-
totalMove.x *= 2;
|
|
467
|
-
totalMove.y *= 2;
|
|
468
|
-
}
|
|
469
466
|
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
470
467
|
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
471
468
|
const signX = sign(originChangedScaleX);
|
|
472
469
|
const signY = sign(originChangedScaleY);
|
|
473
470
|
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
474
471
|
const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
scaleY = bottomScale;
|
|
494
|
-
align = "top";
|
|
495
|
-
break;
|
|
472
|
+
if (isNumber(totalMoveOrScale)) {
|
|
473
|
+
scaleX = scaleY = Math.sqrt(totalMoveOrScale);
|
|
474
|
+
} else {
|
|
475
|
+
if (around) {
|
|
476
|
+
totalMoveOrScale.x *= 2;
|
|
477
|
+
totalMoveOrScale.y *= 2;
|
|
478
|
+
}
|
|
479
|
+
totalMoveOrScale.x *= scaleMode ? originChangedScaleX : signX;
|
|
480
|
+
totalMoveOrScale.y *= scaleMode ? originChangedScaleY : signY;
|
|
481
|
+
const topScale = (-totalMoveOrScale.y + height) / height;
|
|
482
|
+
const rightScale = (totalMoveOrScale.x + width) / width;
|
|
483
|
+
const bottomScale = (totalMoveOrScale.y + height) / height;
|
|
484
|
+
const leftScale = (-totalMoveOrScale.x + width) / width;
|
|
485
|
+
switch (direction) {
|
|
486
|
+
case top:
|
|
487
|
+
scaleY = topScale;
|
|
488
|
+
align = "bottom";
|
|
489
|
+
break;
|
|
496
490
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
491
|
+
case right$1:
|
|
492
|
+
scaleX = rightScale;
|
|
493
|
+
align = "left";
|
|
494
|
+
break;
|
|
501
495
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
break;
|
|
496
|
+
case bottom:
|
|
497
|
+
scaleY = bottomScale;
|
|
498
|
+
align = "top";
|
|
499
|
+
break;
|
|
507
500
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
break;
|
|
501
|
+
case left$1:
|
|
502
|
+
scaleX = leftScale;
|
|
503
|
+
align = "right";
|
|
504
|
+
break;
|
|
513
505
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
506
|
+
case topLeft:
|
|
507
|
+
scaleY = topScale;
|
|
508
|
+
scaleX = leftScale;
|
|
509
|
+
align = "bottom-right";
|
|
510
|
+
break;
|
|
519
511
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (lockRatio) {
|
|
526
|
-
if (lockRatio === "corner" && direction % 2) {
|
|
527
|
-
lockRatio = false;
|
|
528
|
-
} else {
|
|
529
|
-
let scale;
|
|
530
|
-
switch (direction) {
|
|
531
|
-
case top:
|
|
532
|
-
case bottom:
|
|
533
|
-
scale = scaleY;
|
|
534
|
-
break;
|
|
512
|
+
case topRight:
|
|
513
|
+
scaleY = topScale;
|
|
514
|
+
scaleX = rightScale;
|
|
515
|
+
align = "bottom-left";
|
|
516
|
+
break;
|
|
535
517
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
518
|
+
case bottomRight:
|
|
519
|
+
scaleY = bottomScale;
|
|
520
|
+
scaleX = rightScale;
|
|
521
|
+
align = "top-left";
|
|
522
|
+
break;
|
|
540
523
|
|
|
541
|
-
|
|
542
|
-
|
|
524
|
+
case bottomLeft:
|
|
525
|
+
scaleY = bottomScale;
|
|
526
|
+
scaleX = leftScale;
|
|
527
|
+
align = "top-right";
|
|
528
|
+
}
|
|
529
|
+
if (lockRatio) {
|
|
530
|
+
if (lockRatio === "corner" && direction % 2) {
|
|
531
|
+
lockRatio = false;
|
|
532
|
+
} else {
|
|
533
|
+
let scale;
|
|
534
|
+
switch (direction) {
|
|
535
|
+
case top:
|
|
536
|
+
case bottom:
|
|
537
|
+
scale = scaleY;
|
|
538
|
+
break;
|
|
539
|
+
|
|
540
|
+
case left$1:
|
|
541
|
+
case right$1:
|
|
542
|
+
scale = scaleX;
|
|
543
|
+
break;
|
|
544
|
+
|
|
545
|
+
default:
|
|
546
|
+
scale = Math.sqrt(Math.abs(scaleX * scaleY));
|
|
547
|
+
}
|
|
548
|
+
scaleX = scaleX < 0 ? -scale : scale;
|
|
549
|
+
scaleY = scaleY < 0 ? -scale : scale;
|
|
543
550
|
}
|
|
544
|
-
scaleX = scaleX < 0 ? -scale : scale;
|
|
545
|
-
scaleY = scaleY < 0 ? -scale : scale;
|
|
546
551
|
}
|
|
547
552
|
}
|
|
548
553
|
const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
|
|
@@ -830,6 +835,9 @@ class EditBox extends Group {
|
|
|
830
835
|
const {moveable: moveable, resizeable: resizeable, rotateable: rotateable} = this.mergeConfig;
|
|
831
836
|
return isString(moveable) || isString(resizeable) || isString(rotateable);
|
|
832
837
|
}
|
|
838
|
+
get canDragLimitAnimate() {
|
|
839
|
+
return this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds;
|
|
840
|
+
}
|
|
833
841
|
constructor(editor) {
|
|
834
842
|
super();
|
|
835
843
|
this.view = new Group;
|
|
@@ -1063,10 +1071,9 @@ class EditBox extends Group {
|
|
|
1063
1071
|
onDragStart(e) {
|
|
1064
1072
|
this.dragging = true;
|
|
1065
1073
|
const point = this.dragPoint = e.current, {pointType: pointType} = point;
|
|
1066
|
-
const {
|
|
1074
|
+
const {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = this.mergeConfig;
|
|
1067
1075
|
if (pointType === "move") {
|
|
1068
1076
|
moveable && (this.moving = true);
|
|
1069
|
-
editor.opacity = hideOnMove ? 0 : 1;
|
|
1070
1077
|
} else {
|
|
1071
1078
|
if (pointType.includes("rotate") || this.isHoldRotateKey(e) || !resizeable) {
|
|
1072
1079
|
rotateable && (this.rotating = true);
|
|
@@ -1075,23 +1082,7 @@ class EditBox extends Group {
|
|
|
1075
1082
|
} else if (pointType === "resize") resizeable && (this.resizing = true);
|
|
1076
1083
|
if (pointType === "skew") skewable && (this.skewing = true);
|
|
1077
1084
|
}
|
|
1078
|
-
|
|
1079
|
-
dragStartData.y = e.y;
|
|
1080
|
-
dragStartData.point = {
|
|
1081
|
-
x: target.x,
|
|
1082
|
-
y: target.y
|
|
1083
|
-
};
|
|
1084
|
-
dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
|
|
1085
|
-
dragStartData.rotation = target.rotation;
|
|
1086
|
-
if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
1087
|
-
}
|
|
1088
|
-
onDragEnd(e) {
|
|
1089
|
-
if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
|
|
1090
|
-
this.dragPoint = null;
|
|
1091
|
-
this.resetDoing();
|
|
1092
|
-
const {pointType: pointType} = e.current;
|
|
1093
|
-
if (pointType === "move") this.editor.opacity = 1;
|
|
1094
|
-
if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = null;
|
|
1085
|
+
this.onTransformStart(e);
|
|
1095
1086
|
}
|
|
1096
1087
|
onDrag(e) {
|
|
1097
1088
|
const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
|
|
@@ -1106,37 +1097,59 @@ class EditBox extends Group {
|
|
|
1106
1097
|
}
|
|
1107
1098
|
updatePointCursor(this, e);
|
|
1108
1099
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1100
|
+
onDragEnd(e) {
|
|
1101
|
+
this.onTransformEnd(e);
|
|
1102
|
+
this.dragPoint = null;
|
|
1103
|
+
}
|
|
1104
|
+
onTransformStart(e) {
|
|
1105
|
+
if (this.canUse) {
|
|
1106
|
+
if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
1107
|
+
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
|
|
1108
|
+
const {dragStartData: dragStartData, target: target} = this;
|
|
1109
|
+
dragStartData.x = e.x;
|
|
1110
|
+
dragStartData.y = e.y;
|
|
1111
|
+
dragStartData.totalOffset = getPointData();
|
|
1112
|
+
dragStartData.point = {
|
|
1113
|
+
x: target.x,
|
|
1114
|
+
y: target.y
|
|
1115
|
+
};
|
|
1116
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
|
|
1117
|
+
dragStartData.rotation = target.rotation;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
onTransformEnd(e) {
|
|
1121
|
+
if (this.canUse) {
|
|
1122
|
+
if (this.canDragLimitAnimate && (e instanceof DragEvent || e instanceof MoveEvent)) this.transformTool.onMove(e);
|
|
1123
|
+
if (this.resizing) ResizeEvent.resizingKeys = null;
|
|
1124
|
+
this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
|
|
1125
|
+
this.editor.opacity = 1;
|
|
1126
|
+
this.update();
|
|
1127
|
+
}
|
|
1111
1128
|
}
|
|
1112
1129
|
onMove(e) {
|
|
1113
1130
|
if (this.canGesture && e.moveType !== "drag") {
|
|
1114
1131
|
e.stop();
|
|
1115
|
-
if (isString(this.
|
|
1132
|
+
if (isString(this.mergedConfig.moveable)) {
|
|
1116
1133
|
this.gesturing = this.moving = true;
|
|
1117
|
-
this.transformTool.onMove(e);
|
|
1134
|
+
e.type === MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
|
|
1118
1135
|
}
|
|
1119
1136
|
}
|
|
1120
1137
|
}
|
|
1121
|
-
onMoveEnd(e) {
|
|
1122
|
-
if (this.moving) this.transformTool.onMove(e);
|
|
1123
|
-
this.resetDoing();
|
|
1124
|
-
}
|
|
1125
1138
|
onScale(e) {
|
|
1126
1139
|
if (this.canGesture) {
|
|
1127
1140
|
e.stop();
|
|
1128
|
-
if (isString(this.
|
|
1141
|
+
if (isString(this.mergedConfig.resizeable)) {
|
|
1129
1142
|
this.gesturing = this.resizing = true;
|
|
1130
|
-
this.transformTool.onScale(e);
|
|
1143
|
+
e.type === ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
|
|
1131
1144
|
}
|
|
1132
1145
|
}
|
|
1133
1146
|
}
|
|
1134
1147
|
onRotate(e) {
|
|
1135
1148
|
if (this.canGesture) {
|
|
1136
1149
|
e.stop();
|
|
1137
|
-
if (isString(this.
|
|
1150
|
+
if (isString(this.mergedConfig.rotateable)) {
|
|
1138
1151
|
this.gesturing = this.rotating = true;
|
|
1139
|
-
this.transformTool.onRotate(e);
|
|
1152
|
+
e.type === RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
|
|
1140
1153
|
}
|
|
1141
1154
|
}
|
|
1142
1155
|
}
|
|
@@ -1149,8 +1162,7 @@ class EditBox extends Group {
|
|
|
1149
1162
|
updatePointCursor(this, e);
|
|
1150
1163
|
}
|
|
1151
1164
|
onArrow(e) {
|
|
1152
|
-
|
|
1153
|
-
if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
|
|
1165
|
+
if (this.canUse && this.mergeConfig.keyEvent) {
|
|
1154
1166
|
let x = 0, y = 0;
|
|
1155
1167
|
const distance = e.shiftKey ? 10 : 1;
|
|
1156
1168
|
switch (e.code) {
|
|
@@ -1169,7 +1181,7 @@ class EditBox extends Group {
|
|
|
1169
1181
|
case "ArrowRight":
|
|
1170
1182
|
x = distance;
|
|
1171
1183
|
}
|
|
1172
|
-
if (x || y) transformTool.move(x, y);
|
|
1184
|
+
if (x || y) this.transformTool.move(x, y);
|
|
1173
1185
|
}
|
|
1174
1186
|
}
|
|
1175
1187
|
onDoubleTap(e) {
|
|
@@ -1210,7 +1222,7 @@ class EditBox extends Group {
|
|
|
1210
1222
|
const {rect: rect, editor: editor, __eventIds: events} = this;
|
|
1211
1223
|
events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
|
|
1212
1224
|
this.waitLeafer(() => {
|
|
1213
|
-
events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ MoveEvent.END,
|
|
1225
|
+
events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ [ MoveEvent.START, MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ ZoomEvent.START, ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ RotateEvent.START, RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ MoveEvent.END, ZoomEvent.END, RotateEvent.END ], this.onTransformEnd, this ] ]));
|
|
1214
1226
|
});
|
|
1215
1227
|
}
|
|
1216
1228
|
__removeListenEvents() {
|
|
@@ -1608,56 +1620,61 @@ class TransformTool {
|
|
|
1608
1620
|
const isMoveEnd = e.type === MoveEvent.END || e.type === DragEvent.END;
|
|
1609
1621
|
const axisDrag = isString(target.draggable);
|
|
1610
1622
|
const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
|
|
1623
|
+
const total = {
|
|
1624
|
+
x: e.totalX,
|
|
1625
|
+
y: e.totalY
|
|
1626
|
+
};
|
|
1611
1627
|
if (e instanceof MoveEvent) {
|
|
1612
|
-
move
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
x: e.totalX,
|
|
1617
|
-
y: e.totalY
|
|
1618
|
-
};
|
|
1619
|
-
if (e.shiftKey) {
|
|
1620
|
-
if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
|
|
1621
|
-
}
|
|
1622
|
-
move = DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
|
|
1628
|
+
PointHelper.move(total, target.getWorldPointByLocal(dragStartData.totalOffset, null, true));
|
|
1629
|
+
}
|
|
1630
|
+
if (e.shiftKey) {
|
|
1631
|
+
if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
|
|
1623
1632
|
}
|
|
1633
|
+
move = DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
|
|
1624
1634
|
if (move.x || move.y) {
|
|
1625
1635
|
if (dragLimitAnimate && !axisDrag && isMoveEnd) LeafHelper.animateMove(this, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else this.move(move);
|
|
1626
1636
|
}
|
|
1627
1637
|
}
|
|
1628
1638
|
onScale(e) {
|
|
1629
1639
|
const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
|
|
1630
|
-
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig;
|
|
1640
|
+
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
|
|
1631
1641
|
if (e instanceof ZoomEvent) {
|
|
1632
|
-
|
|
1642
|
+
around = target.getBoxPoint(e);
|
|
1643
|
+
totalMove = e.totalScale;
|
|
1633
1644
|
} else {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1645
|
+
totalMove = e.getInnerTotal(target);
|
|
1646
|
+
}
|
|
1647
|
+
const {direction: direction} = e.current;
|
|
1648
|
+
if (e.shiftKey || target.lockRatio) lockRatio = true;
|
|
1649
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
|
|
1650
|
+
const targetX = target.x, targetY = target.y;
|
|
1651
|
+
if (e instanceof DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
|
|
1652
|
+
data.drag = e;
|
|
1653
|
+
this.scaleWithDrag(data);
|
|
1654
|
+
} else {
|
|
1655
|
+
this.scaleOf(data.origin, data.scaleX, data.scaleY);
|
|
1643
1656
|
}
|
|
1657
|
+
PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
|
|
1644
1658
|
}
|
|
1645
1659
|
onRotate(e) {
|
|
1646
1660
|
const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
|
|
1647
|
-
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap} = mergeConfig;
|
|
1661
|
+
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
|
|
1648
1662
|
const {direction: direction} = e.current;
|
|
1649
1663
|
let origin, rotation;
|
|
1650
1664
|
if (e instanceof RotateEvent) {
|
|
1651
1665
|
rotation = e.rotation;
|
|
1652
1666
|
origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
|
|
1653
1667
|
} else {
|
|
1654
|
-
const
|
|
1668
|
+
const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
|
|
1669
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
|
|
1655
1670
|
rotation = dragStartData.rotation + data.rotation - target.rotation;
|
|
1656
1671
|
origin = data.origin;
|
|
1657
1672
|
}
|
|
1658
1673
|
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
|
|
1659
1674
|
if (!rotation) return;
|
|
1675
|
+
const targetX = target.x, targetY = target.y;
|
|
1660
1676
|
this.rotateOf(origin, rotation);
|
|
1677
|
+
PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
|
|
1661
1678
|
}
|
|
1662
1679
|
onSkew(e) {
|
|
1663
1680
|
const {target: target, mergeConfig: mergeConfig} = this.editBox;
|