@leafer-in/editor 1.9.6 → 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.js CHANGED
@@ -41,22 +41,25 @@ this.LeaferIN.editor = function(exports, draw, core) {
41
41
  set(value) {
42
42
  const old = this[privateKey];
43
43
  if (old !== value) {
44
- if (this.config) {
44
+ const t = this;
45
+ if (t.config) {
45
46
  const isSelect = key === "target";
46
47
  if (isSelect) {
47
- if (draw.isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
48
- if (this.single) this.element.syncEventer = null;
49
- const {beforeSelect: beforeSelect} = this.config;
48
+ const {beforeSelect: beforeSelect} = t.config;
50
49
  if (beforeSelect) {
51
50
  const check = beforeSelect({
52
51
  target: value
53
52
  });
54
53
  if (draw.isObject(check)) value = check; else if (check === false) return;
55
54
  }
55
+ t.setDimOthers(false);
56
+ t.setBright(false);
57
+ if (draw.isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
58
+ if (t.single) t.element.syncEventer = null;
56
59
  }
57
60
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
58
61
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
59
- editor: this,
62
+ editor: t,
60
63
  value: value,
61
64
  oldValue: old
62
65
  }));
@@ -223,11 +226,12 @@ this.LeaferIN.editor = function(exports, draw, core) {
223
226
  return !!this.originList;
224
227
  }
225
228
  get running() {
226
- const {editor: editor} = this;
227
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
229
+ const {editor: editor, app: app} = this;
230
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && (app && app.mode === "normal");
228
231
  }
229
232
  get isMoveMode() {
230
- return this.app && this.app.interaction.moveMode;
233
+ const {app: app} = this;
234
+ return app && app.interaction.moveMode;
231
235
  }
232
236
  constructor(editor) {
233
237
  super();
@@ -290,12 +294,12 @@ this.LeaferIN.editor = function(exports, draw, core) {
290
294
  onTap(e) {
291
295
  if (e.multiTouch) return;
292
296
  const {editor: editor} = this;
293
- const {select: select} = editor.mergeConfig;
297
+ const {select: select, selectKeep: selectKeep} = editor.mergeConfig;
294
298
  if (select === "tap") this.checkAndSelect(e); else if (this.waitSelect) this.waitSelect();
295
299
  if (this.needRemoveItem) {
296
300
  editor.removeItem(this.needRemoveItem);
297
301
  } else if (this.isMoveMode) {
298
- editor.target = null;
302
+ if (!selectKeep) editor.target = null;
299
303
  }
300
304
  }
301
305
  checkAndSelect(e) {
@@ -310,7 +314,7 @@ this.LeaferIN.editor = function(exports, draw, core) {
310
314
  editor.target = find;
311
315
  }
312
316
  } else if (this.allow(e.target)) {
313
- if (!this.isHoldMultipleSelectKey(e)) editor.target = null;
317
+ if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
314
318
  }
315
319
  }
316
320
  }
@@ -425,91 +429,95 @@ this.LeaferIN.editor = function(exports, draw, core) {
425
429
  const {toPoint: toPoint} = draw.AroundHelper;
426
430
  const {within: within, sign: sign} = draw.MathHelper;
427
431
  const EditDataHelper = {
428
- getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
432
+ getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
429
433
  let align, origin = {}, scaleX = 1, scaleY = 1;
430
434
  const {boxBounds: boxBounds, widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldBoxBounds: worldBoxBounds} = target;
431
435
  const {width: width, height: height} = startBounds;
432
- if (around) {
433
- totalMove.x *= 2;
434
- totalMove.y *= 2;
435
- }
436
436
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
437
437
  const originChangedScaleY = target.scaleY / startBounds.scaleY;
438
438
  const signX = sign(originChangedScaleX);
439
439
  const signY = sign(originChangedScaleY);
440
440
  const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
441
441
  const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
442
- totalMove.x *= scaleMode ? originChangedScaleX : signX;
443
- totalMove.y *= scaleMode ? originChangedScaleY : signY;
444
- const topScale = (-totalMove.y + height) / height;
445
- const rightScale = (totalMove.x + width) / width;
446
- const bottomScale = (totalMove.y + height) / height;
447
- const leftScale = (-totalMove.x + width) / width;
448
- switch (direction) {
449
- case top:
450
- scaleY = topScale;
451
- align = "bottom";
452
- break;
442
+ if (draw.isNumber(totalMoveOrScale)) {
443
+ scaleX = scaleY = Math.sqrt(totalMoveOrScale);
444
+ } else {
445
+ if (around) {
446
+ totalMoveOrScale.x *= 2;
447
+ totalMoveOrScale.y *= 2;
448
+ }
449
+ totalMoveOrScale.x *= scaleMode ? originChangedScaleX : signX;
450
+ totalMoveOrScale.y *= scaleMode ? originChangedScaleY : signY;
451
+ const topScale = (-totalMoveOrScale.y + height) / height;
452
+ const rightScale = (totalMoveOrScale.x + width) / width;
453
+ const bottomScale = (totalMoveOrScale.y + height) / height;
454
+ const leftScale = (-totalMoveOrScale.x + width) / width;
455
+ switch (direction) {
456
+ case top:
457
+ scaleY = topScale;
458
+ align = "bottom";
459
+ break;
453
460
 
454
- case right$1:
455
- scaleX = rightScale;
456
- align = "left";
457
- break;
461
+ case right$1:
462
+ scaleX = rightScale;
463
+ align = "left";
464
+ break;
458
465
 
459
- case bottom:
460
- scaleY = bottomScale;
461
- align = "top";
462
- break;
466
+ case bottom:
467
+ scaleY = bottomScale;
468
+ align = "top";
469
+ break;
463
470
 
464
- case left$1:
465
- scaleX = leftScale;
466
- align = "right";
467
- break;
471
+ case left$1:
472
+ scaleX = leftScale;
473
+ align = "right";
474
+ break;
468
475
 
469
- case topLeft:
470
- scaleY = topScale;
471
- scaleX = leftScale;
472
- align = "bottom-right";
473
- break;
476
+ case topLeft:
477
+ scaleY = topScale;
478
+ scaleX = leftScale;
479
+ align = "bottom-right";
480
+ break;
474
481
 
475
- case topRight:
476
- scaleY = topScale;
477
- scaleX = rightScale;
478
- align = "bottom-left";
479
- break;
482
+ case topRight:
483
+ scaleY = topScale;
484
+ scaleX = rightScale;
485
+ align = "bottom-left";
486
+ break;
480
487
 
481
- case bottomRight:
482
- scaleY = bottomScale;
483
- scaleX = rightScale;
484
- align = "top-left";
485
- break;
488
+ case bottomRight:
489
+ scaleY = bottomScale;
490
+ scaleX = rightScale;
491
+ align = "top-left";
492
+ break;
486
493
 
487
- case bottomLeft:
488
- scaleY = bottomScale;
489
- scaleX = leftScale;
490
- align = "top-right";
491
- }
492
- if (lockRatio) {
493
- if (lockRatio === "corner" && direction % 2) {
494
- lockRatio = false;
495
- } else {
496
- let scale;
497
- switch (direction) {
498
- case top:
499
- case bottom:
500
- scale = scaleY;
501
- break;
494
+ case bottomLeft:
495
+ scaleY = bottomScale;
496
+ scaleX = leftScale;
497
+ align = "top-right";
498
+ }
499
+ if (lockRatio) {
500
+ if (lockRatio === "corner" && direction % 2) {
501
+ lockRatio = false;
502
+ } else {
503
+ let scale;
504
+ switch (direction) {
505
+ case top:
506
+ case bottom:
507
+ scale = scaleY;
508
+ break;
502
509
 
503
- case left$1:
504
- case right$1:
505
- scale = scaleX;
506
- break;
510
+ case left$1:
511
+ case right$1:
512
+ scale = scaleX;
513
+ break;
507
514
 
508
- default:
509
- scale = Math.sqrt(Math.abs(scaleX * scaleY));
515
+ default:
516
+ scale = Math.sqrt(Math.abs(scaleX * scaleY));
517
+ }
518
+ scaleX = scaleX < 0 ? -scale : scale;
519
+ scaleY = scaleY < 0 ? -scale : scale;
510
520
  }
511
- scaleX = scaleX < 0 ? -scale : scale;
512
- scaleY = scaleY < 0 ? -scale : scale;
513
521
  }
514
522
  }
515
523
  const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
@@ -706,13 +714,18 @@ this.LeaferIN.editor = function(exports, draw, core) {
706
714
  function updatePointCursor(editBox, e) {
707
715
  const {enterPoint: point, dragging: dragging, skewing: skewing, resizing: resizing, flippedX: flippedX, flippedY: flippedY} = editBox;
708
716
  if (!point || !editBox.editor.editing || !editBox.canUse) return;
717
+ if (point.name === "rect") return updateMoveCursor(editBox);
709
718
  if (point.name === "circle") return;
710
- if (point.pointType === "button") {
719
+ let {rotation: rotation} = editBox;
720
+ const {pointType: pointType} = point, {moveCursor: moveCursor, resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
721
+ if (pointType === "move") {
722
+ point.cursor = moveCursor;
723
+ if (!moveable) point.visible = false;
724
+ return;
725
+ } else if (pointType === "button") {
711
726
  if (!point.cursor) point.cursor = "pointer";
712
727
  return;
713
728
  }
714
- let {rotation: rotation} = editBox;
715
- const {pointType: pointType} = point, {resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
716
729
  let showResize = pointType.includes("resize");
717
730
  if (showResize && rotateable && (editBox.isHoldRotateKey(e) || !resizeable)) showResize = false;
718
731
  const showSkew = skewable && !showResize && (point.name === "resize-line" || pointType === "skew");
@@ -785,10 +798,13 @@ this.LeaferIN.editor = function(exports, draw, core) {
785
798
  const {moveable: moveable, resizeable: resizeable, rotateable: rotateable} = this.mergeConfig;
786
799
  return draw.isString(moveable) || draw.isString(resizeable) || draw.isString(rotateable);
787
800
  }
801
+ get canDragLimitAnimate() {
802
+ return this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds;
803
+ }
788
804
  constructor(editor) {
789
805
  super();
790
806
  this.view = new draw.Group;
791
- this.rect = new draw.Box({
807
+ this.rect = new EditPoint({
792
808
  name: "rect",
793
809
  hitFill: "all",
794
810
  hitStroke: "none",
@@ -850,12 +866,13 @@ this.LeaferIN.editor = function(exports, draw, core) {
850
866
  this.listenPointEvents(resizePoint, "resize", i);
851
867
  }
852
868
  this.listenPointEvents(circle, "rotate", 2);
869
+ this.listenPointEvents(rect, "move", 8);
853
870
  view.addMany(...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints);
854
871
  this.add(view);
855
872
  }
856
873
  load() {
857
- const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints} = this;
858
- const {stroke: stroke, strokeWidth: strokeWidth} = mergeConfig;
874
+ const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
875
+ const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine} = mergeConfig;
859
876
  const pointsStyle = this.getPointsStyle();
860
877
  const middlePointsStyle = this.getMiddlePointsStyle();
861
878
  this.visible = !target.locked;
@@ -864,6 +881,10 @@ this.LeaferIN.editor = function(exports, draw, core) {
864
881
  resizeP = resizePoints[i];
865
882
  resizeP.set(this.getPointStyle(i % 2 ? middlePointsStyle[(i - 1) / 2 % middlePointsStyle.length] : pointsStyle[i / 2 % pointsStyle.length]));
866
883
  resizeP.rotation = (i - (i % 2 ? 1 : 0)) / 2 * 90;
884
+ if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
885
+ pointType: "resize",
886
+ rotation: (i - 1) / 2 * 90
887
+ }, resizeLine || {}));
867
888
  }
868
889
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
869
890
  rect.set(Object.assign({
@@ -908,10 +929,12 @@ this.LeaferIN.editor = function(exports, draw, core) {
908
929
  if (this.app) this.rect.syncEventer = this.app.interaction.bottomList = null;
909
930
  }
910
931
  updateBounds(bounds) {
911
- const {editMask: editMask} = this.editor;
912
- const {mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
913
- const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
932
+ const {editor: editor, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
933
+ const {editMask: editMask} = editor;
934
+ const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, dimOthers: dimOthers, bright: bright, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
914
935
  editMask.visible = mask ? true : 0;
936
+ editor.setDimOthers(dimOthers);
937
+ editor.setBright(!!dimOthers || bright);
915
938
  if (spread) draw.BoundsHelper.spread(bounds, spread);
916
939
  if (this.view.worldOpacity) {
917
940
  const {width: width, height: height} = bounds;
@@ -932,10 +955,10 @@ this.LeaferIN.editor = function(exports, draw, core) {
932
955
  resizeL.visible = resizeP.visible && !hideResizeLines;
933
956
  resizeP.visible = rotateP.visible = showPoints && !!middlePoint;
934
957
  if ((i + 1) / 2 % 2) {
935
- resizeL.width = width;
958
+ resizeL.width = width + resizeL.height;
936
959
  if (hideOnSmall && resizeP.width * 2 > width) resizeP.visible = false;
937
960
  } else {
938
- resizeL.height = height;
961
+ resizeL.width = height + resizeL.height;
939
962
  if (hideOnSmall && resizeP.width * 2 > height) resizeP.visible = false;
940
963
  }
941
964
  }
@@ -1011,10 +1034,9 @@ this.LeaferIN.editor = function(exports, draw, core) {
1011
1034
  onDragStart(e) {
1012
1035
  this.dragging = true;
1013
1036
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
1014
- const {editor: editor, dragStartData: dragStartData} = this, {target: target} = this, {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable, hideOnMove: hideOnMove} = this.mergeConfig;
1015
- if (point.name === "rect") {
1037
+ const {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = this.mergeConfig;
1038
+ if (pointType === "move") {
1016
1039
  moveable && (this.moving = true);
1017
- editor.opacity = hideOnMove ? 0 : 1;
1018
1040
  } else {
1019
1041
  if (pointType.includes("rotate") || this.isHoldRotateKey(e) || !resizeable) {
1020
1042
  rotateable && (this.rotating = true);
@@ -1023,69 +1045,74 @@ this.LeaferIN.editor = function(exports, draw, core) {
1023
1045
  } else if (pointType === "resize") resizeable && (this.resizing = true);
1024
1046
  if (pointType === "skew") skewable && (this.skewing = true);
1025
1047
  }
1026
- dragStartData.x = e.x;
1027
- dragStartData.y = e.y;
1028
- dragStartData.point = {
1029
- x: target.x,
1030
- y: target.y
1031
- };
1032
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
1033
- dragStartData.rotation = target.rotation;
1034
- if (pointType && pointType.includes("resize")) draw.ResizeEvent.resizingKeys = editor.leafList.keys;
1035
- }
1036
- onDragEnd(e) {
1037
- if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
1038
- this.dragPoint = null;
1039
- this.resetDoing();
1040
- const {name: name, pointType: pointType} = e.current;
1041
- if (name === "rect") this.editor.opacity = 1;
1042
- if (pointType && pointType.includes("resize")) draw.ResizeEvent.resizingKeys = null;
1048
+ this.onTransformStart(e);
1043
1049
  }
1044
1050
  onDrag(e) {
1045
1051
  const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
1046
1052
  if (moving) {
1047
1053
  transformTool.onMove(e);
1048
- updateMoveCursor(this);
1049
1054
  } else if (resizing || rotating || skewing) {
1050
1055
  const point = e.current;
1051
1056
  if (point.pointType) this.enterPoint = point;
1052
1057
  if (rotating) transformTool.onRotate(e);
1053
1058
  if (resizing) transformTool.onScale(e);
1054
1059
  if (skewing) transformTool.onSkew(e);
1055
- updatePointCursor(this, e);
1056
1060
  }
1061
+ updatePointCursor(this, e);
1057
1062
  }
1058
- resetDoing() {
1059
- if (this.canUse) this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
1063
+ onDragEnd(e) {
1064
+ this.onTransformEnd(e);
1065
+ this.dragPoint = null;
1066
+ }
1067
+ onTransformStart(e) {
1068
+ if (this.canUse) {
1069
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
1070
+ if (this.resizing) draw.ResizeEvent.resizingKeys = this.editor.leafList.keys;
1071
+ const {dragStartData: dragStartData, target: target} = this;
1072
+ dragStartData.x = e.x;
1073
+ dragStartData.y = e.y;
1074
+ dragStartData.totalOffset = draw.getPointData();
1075
+ dragStartData.point = {
1076
+ x: target.x,
1077
+ y: target.y
1078
+ };
1079
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
1080
+ dragStartData.rotation = target.rotation;
1081
+ }
1082
+ }
1083
+ onTransformEnd(e) {
1084
+ if (this.canUse) {
1085
+ if (this.canDragLimitAnimate && (e instanceof core.DragEvent || e instanceof core.MoveEvent)) this.transformTool.onMove(e);
1086
+ if (this.resizing) draw.ResizeEvent.resizingKeys = null;
1087
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
1088
+ this.editor.opacity = 1;
1089
+ this.update();
1090
+ }
1060
1091
  }
1061
1092
  onMove(e) {
1062
1093
  if (this.canGesture && e.moveType !== "drag") {
1063
1094
  e.stop();
1064
- if (draw.isString(this.mergeConfig.moveable)) {
1095
+ if (draw.isString(this.mergedConfig.moveable)) {
1065
1096
  this.gesturing = this.moving = true;
1066
- this.transformTool.onMove(e);
1097
+ e.type === core.MoveEvent.START ? this.onTransformStart(e) : this.transformTool.onMove(e);
1067
1098
  }
1068
1099
  }
1069
1100
  }
1070
- onMoveEnd(e) {
1071
- if (this.moving) this.transformTool.onMove(e);
1072
- this.resetDoing();
1073
- }
1074
1101
  onScale(e) {
1075
1102
  if (this.canGesture) {
1076
1103
  e.stop();
1077
- if (draw.isString(this.mergeConfig.resizeable)) {
1104
+ if (draw.isString(this.mergedConfig.resizeable)) {
1078
1105
  this.gesturing = this.resizing = true;
1079
- this.transformTool.onScale(e);
1106
+ e.type === core.ZoomEvent.START ? this.onTransformStart(e) : this.transformTool.onScale(e);
1080
1107
  }
1081
1108
  }
1082
1109
  }
1083
1110
  onRotate(e) {
1084
1111
  if (this.canGesture) {
1085
1112
  e.stop();
1086
- if (draw.isString(this.mergeConfig.rotateable)) {
1113
+ if (draw.isString(this.mergedConfig.rotateable)) {
1087
1114
  this.gesturing = this.rotating = true;
1088
- this.transformTool.onRotate(e);
1115
+ e.type === core.RotateEvent.START ? this.onTransformStart(e) : this.transformTool.onRotate(e);
1089
1116
  }
1090
1117
  }
1091
1118
  }
@@ -1098,8 +1125,7 @@ this.LeaferIN.editor = function(exports, draw, core) {
1098
1125
  updatePointCursor(this, e);
1099
1126
  }
1100
1127
  onArrow(e) {
1101
- const {editor: editor, transformTool: transformTool} = this;
1102
- if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
1128
+ if (this.canUse && this.mergeConfig.keyEvent) {
1103
1129
  let x = 0, y = 0;
1104
1130
  const distance = e.shiftKey ? 10 : 1;
1105
1131
  switch (e.code) {
@@ -1118,7 +1144,7 @@ this.LeaferIN.editor = function(exports, draw, core) {
1118
1144
  case "ArrowRight":
1119
1145
  x = distance;
1120
1146
  }
1121
- if (x || y) transformTool.move(x, y);
1147
+ if (x || y) this.transformTool.move(x, y);
1122
1148
  }
1123
1149
  }
1124
1150
  onDoubleTap(e) {
@@ -1149,19 +1175,17 @@ this.LeaferIN.editor = function(exports, draw, core) {
1149
1175
  listenPointEvents(point, type, direction) {
1150
1176
  point.direction = direction;
1151
1177
  point.pointType = type;
1152
- const events = [ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.LEAVE, () => {
1153
- this.enterPoint = null;
1154
- } ] ];
1155
- if (point.name !== "circle") events.push([ core.PointerEvent.ENTER, e => {
1178
+ this.__eventIds.push(point.on_([ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.ENTER, e => {
1156
1179
  this.enterPoint = point, updatePointCursor(this, e);
1157
- } ]);
1158
- this.__eventIds.push(point.on_(events));
1180
+ } ], [ core.PointerEvent.LEAVE, () => {
1181
+ this.enterPoint = null;
1182
+ } ] ]));
1159
1183
  }
1160
1184
  __listenEvents() {
1161
1185
  const {rect: rect, editor: editor, __eventIds: events} = this;
1162
- events.push(rect.on_([ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.ENTER, () => updateMoveCursor(this) ], [ core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ core.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1186
+ events.push(rect.on_([ [ core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ core.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1163
1187
  this.waitLeafer(() => {
1164
- 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, this.onMoveEnd, this ], [ core.ZoomEvent.END, this.resetDoing, this ], [ core.RotateEvent.END, this.resetDoing, this ] ]));
1188
+ 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 ] ]));
1165
1189
  });
1166
1190
  }
1167
1191
  __removeListenEvents() {
@@ -1510,56 +1534,61 @@ this.LeaferIN.editor = function(exports, draw, core) {
1510
1534
  const isMoveEnd = e.type === core.MoveEvent.END || e.type === core.DragEvent.END;
1511
1535
  const axisDrag = draw.isString(target.draggable);
1512
1536
  const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
1537
+ const total = {
1538
+ x: e.totalX,
1539
+ y: e.totalY
1540
+ };
1513
1541
  if (e instanceof core.MoveEvent) {
1514
- move = e.getLocalMove(target);
1515
- if (checkLimitMove) core.DragEvent.limitMove(target, move);
1516
- } else {
1517
- const total = {
1518
- x: e.totalX,
1519
- y: e.totalY
1520
- };
1521
- if (e.shiftKey) {
1522
- if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
1523
- }
1524
- move = core.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
1542
+ draw.PointHelper.move(total, target.getWorldPointByLocal(dragStartData.totalOffset, null, true));
1543
+ }
1544
+ if (e.shiftKey) {
1545
+ if (Math.abs(total.x) > Math.abs(total.y)) total.y = 0; else total.x = 0;
1525
1546
  }
1547
+ move = core.DragEvent.getValidMove(target, dragStartData.point, total, checkLimitMove);
1526
1548
  if (move.x || move.y) {
1527
1549
  if (dragLimitAnimate && !axisDrag && isMoveEnd) draw.LeafHelper.animateMove(this, move, draw.isNumber(dragLimitAnimate) ? dragLimitAnimate : .3); else this.move(move);
1528
1550
  }
1529
1551
  }
1530
1552
  onScale(e) {
1531
1553
  const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
1532
- let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig;
1554
+ let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
1533
1555
  if (e instanceof core.ZoomEvent) {
1534
- this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
1556
+ around = target.getBoxPoint(e);
1557
+ totalMove = e.totalScale;
1535
1558
  } else {
1536
- const {direction: direction} = e.current;
1537
- if (e.shiftKey || target.lockRatio) lockRatio = true;
1538
- const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
1539
- if (this.editTool && this.editTool.onScaleWithDrag) {
1540
- data.drag = e;
1541
- this.scaleWithDrag(data);
1542
- } else {
1543
- this.scaleOf(data.origin, data.scaleX, data.scaleY);
1544
- }
1559
+ totalMove = e.getInnerTotal(target);
1560
+ }
1561
+ const {direction: direction} = e.current;
1562
+ if (e.shiftKey || target.lockRatio) lockRatio = true;
1563
+ const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
1564
+ const targetX = target.x, targetY = target.y;
1565
+ if (e instanceof core.DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
1566
+ data.drag = e;
1567
+ this.scaleWithDrag(data);
1568
+ } else {
1569
+ this.scaleOf(data.origin, data.scaleX, data.scaleY);
1545
1570
  }
1571
+ draw.PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
1546
1572
  }
1547
1573
  onRotate(e) {
1548
1574
  const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
1549
- const {around: around, rotateAround: rotateAround, rotateGap: rotateGap} = mergeConfig;
1575
+ const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
1550
1576
  const {direction: direction} = e.current;
1551
1577
  let origin, rotation;
1552
1578
  if (e instanceof core.RotateEvent) {
1553
1579
  rotation = e.rotation;
1554
1580
  origin = rotateAround ? draw.AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
1555
1581
  } else {
1556
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : rotateAround || target.around || target.origin || around || "center");
1582
+ const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
1583
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
1557
1584
  rotation = dragStartData.rotation + data.rotation - target.rotation;
1558
1585
  origin = data.origin;
1559
1586
  }
1560
1587
  rotation = draw.MathHelper.float(draw.MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
1561
1588
  if (!rotation) return;
1589
+ const targetX = target.x, targetY = target.y;
1562
1590
  this.rotateOf(origin, rotation);
1591
+ draw.PointHelper.move(dragStartData.totalOffset, target.x - targetX, target.y - targetY);
1563
1592
  }
1564
1593
  onSkew(e) {
1565
1594
  const {target: target, mergeConfig: mergeConfig} = this.editBox;
@@ -1837,6 +1866,16 @@ this.LeaferIN.editor = function(exports, draw, core) {
1837
1866
  shiftItem(item) {
1838
1867
  this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
1839
1868
  }
1869
+ setDimOthers(value, attrName = "dim", list) {
1870
+ if (!list) {
1871
+ const {dimTarget: dimTarget, targetLeafer: targetLeafer} = this;
1872
+ list = dimTarget ? draw.isArray(dimTarget) ? dimTarget : [ dimTarget ] : [ targetLeafer ];
1873
+ }
1874
+ if (list[0] && list[0][attrName] !== (value || false)) list.forEach(item => draw.DataHelper.stintSet(item, attrName, value));
1875
+ }
1876
+ setBright(value) {
1877
+ this.setDimOthers(value, "bright", this.list);
1878
+ }
1840
1879
  update() {
1841
1880
  if (this.editing) {
1842
1881
  if (!this.element.parent) return this.cancel();
@@ -2057,8 +2096,8 @@ this.LeaferIN.editor = function(exports, draw, core) {
2057
2096
  }
2058
2097
  };
2059
2098
  __decorate([ mergeConfigAttr() ], exports.Editor.prototype, "mergeConfig", void 0);
2060
- __decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
2061
2099
  __decorate([ targetAttr(onTarget) ], exports.Editor.prototype, "target", void 0);
2100
+ __decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
2062
2101
  exports.Editor = __decorate([ core.useModule(TransformTool, [ "editBox", "editTool", "emitEvent" ]) ], exports.Editor);
2063
2102
  class InnerEditor {
2064
2103
  static registerInnerEditor() {