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