@leafer/miniapp 2.1.10 → 2.2.0
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/miniapp.module.js +147 -96
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +25 -25
package/dist/miniapp.module.js
CHANGED
|
@@ -817,6 +817,11 @@ const PointHelper = {
|
|
|
817
817
|
toOuterOf(t, matrix, to) {
|
|
818
818
|
toOuterPoint$4(matrix, t, to);
|
|
819
819
|
},
|
|
820
|
+
toVertical(t, rotation, verticalDistance, to) {
|
|
821
|
+
const r = rotation * OneRadian;
|
|
822
|
+
t.x += -Math.sin(r) * verticalDistance;
|
|
823
|
+
t.y += Math.cos(r) * verticalDistance;
|
|
824
|
+
},
|
|
820
825
|
getCenter(t, to) {
|
|
821
826
|
return {
|
|
822
827
|
x: t.x + (to.x - t.x) / 2,
|
|
@@ -1256,7 +1261,6 @@ const BoundsHelper = {
|
|
|
1256
1261
|
},
|
|
1257
1262
|
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
1258
1263
|
const {x: x, y: y, width: width, height: height} = bounds;
|
|
1259
|
-
if (!spread) spread = 0;
|
|
1260
1264
|
if (isArray(spread)) {
|
|
1261
1265
|
const four = fourNumber$1(spread);
|
|
1262
1266
|
isShrink ? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0]) : B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
@@ -3577,7 +3581,8 @@ const PathDrawer = {
|
|
|
3577
3581
|
return;
|
|
3578
3582
|
}
|
|
3579
3583
|
}
|
|
3580
|
-
}
|
|
3584
|
+
},
|
|
3585
|
+
drawPathByPoints(_drawer, _points, _closed) {}
|
|
3581
3586
|
};
|
|
3582
3587
|
|
|
3583
3588
|
const {M: M$7, L: L$7, C: C$5, Q: Q$3, Z: Z$5, N: N$2, D: D$3, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2} = PathCommandMap;
|
|
@@ -6985,7 +6990,7 @@ class LeafLevelList {
|
|
|
6985
6990
|
}
|
|
6986
6991
|
}
|
|
6987
6992
|
|
|
6988
|
-
const version = "2.
|
|
6993
|
+
const version = "2.2.0";
|
|
6989
6994
|
|
|
6990
6995
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6991
6996
|
get allowBackgroundColor() {
|
|
@@ -8688,8 +8693,9 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8688
8693
|
this.__drawPathByData(canvas, data.__pathForRender);
|
|
8689
8694
|
}
|
|
8690
8695
|
__drawPath(canvas) {
|
|
8696
|
+
const data = this.__;
|
|
8691
8697
|
canvas.beginPath();
|
|
8692
|
-
this.__drawPathByData(canvas,
|
|
8698
|
+
data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
|
|
8693
8699
|
}
|
|
8694
8700
|
__drawPathByData(drawer, data, ignoreCornerRadius) {
|
|
8695
8701
|
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
|
|
@@ -9546,6 +9552,9 @@ let Polygon = class Polygon extends UI {
|
|
|
9546
9552
|
get __tag() {
|
|
9547
9553
|
return "Polygon";
|
|
9548
9554
|
}
|
|
9555
|
+
get isPointsMode() {
|
|
9556
|
+
return this.points && !this.pathInputed;
|
|
9557
|
+
}
|
|
9549
9558
|
__updatePath() {
|
|
9550
9559
|
const data = this.__;
|
|
9551
9560
|
const path = data.path = [];
|
|
@@ -9623,6 +9632,9 @@ let Line = class Line extends UI {
|
|
|
9623
9632
|
get __tag() {
|
|
9624
9633
|
return "Line";
|
|
9625
9634
|
}
|
|
9635
|
+
get isPointsMode() {
|
|
9636
|
+
return this.points && !this.pathInputed;
|
|
9637
|
+
}
|
|
9626
9638
|
get toPoint() {
|
|
9627
9639
|
const {width: width, rotation: rotation} = this.__;
|
|
9628
9640
|
const to = getPointData();
|
|
@@ -9781,7 +9793,7 @@ let Text = class Text extends UI {
|
|
|
9781
9793
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9782
9794
|
stintSet$3(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9783
9795
|
stintSet$3(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9784
|
-
stintSet$3(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9796
|
+
stintSet$3(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9785
9797
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9786
9798
|
}
|
|
9787
9799
|
__updateBoxBounds() {
|
|
@@ -9806,7 +9818,7 @@ let Text = class Text extends UI {
|
|
|
9806
9818
|
this.__updateNaturalSize();
|
|
9807
9819
|
} else super.__updateBoxBounds();
|
|
9808
9820
|
if (italic) b.width += fontSize * .16;
|
|
9809
|
-
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
9821
|
+
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
|
|
9810
9822
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
9811
9823
|
}
|
|
9812
9824
|
__updateRenderSpread() {
|
|
@@ -11409,8 +11421,10 @@ ui$5.__hit = function(inner, forceHitFill) {
|
|
|
11409
11421
|
if (!needHitFillPath && !needHitStrokePath) return false;
|
|
11410
11422
|
const radiusWidth = inner.radiusX * 2;
|
|
11411
11423
|
let hitWidth = radiusWidth;
|
|
11424
|
+
let {strokeAlign: strokeAlign} = data;
|
|
11425
|
+
if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
|
|
11412
11426
|
if (needHitStrokePath) {
|
|
11413
|
-
switch (
|
|
11427
|
+
switch (strokeAlign) {
|
|
11414
11428
|
case "inside":
|
|
11415
11429
|
hitWidth += strokeWidth * 2;
|
|
11416
11430
|
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
|
|
@@ -11444,9 +11458,9 @@ rect.__hitFill = box$3.__hitFill = function(inner) {
|
|
|
11444
11458
|
};
|
|
11445
11459
|
|
|
11446
11460
|
Text.prototype.__drawHitPath = function(canvas) {
|
|
11447
|
-
const {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData:
|
|
11461
|
+
const data = this.__, {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: drawData} = data;
|
|
11448
11462
|
canvas.beginPath();
|
|
11449
|
-
if (__letterSpacing < 0) this.__drawPathByBox(canvas); else
|
|
11463
|
+
if (data.motionText) this.__drawPathByData(canvas, data.__pathForMotionText); else if (__letterSpacing < 0) this.__drawPathByBox(canvas); else drawData.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
11450
11464
|
};
|
|
11451
11465
|
|
|
11452
11466
|
Group.prototype.pick = function(hitPoint, options) {
|
|
@@ -11633,7 +11647,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
|
|
|
11633
11647
|
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11634
11648
|
}
|
|
11635
11649
|
|
|
11636
|
-
function fillText(ui, canvas,
|
|
11650
|
+
function fillText(ui, canvas, renderOptions) {
|
|
11651
|
+
if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11637
11652
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11638
11653
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11639
11654
|
let row;
|
|
@@ -12995,7 +13010,8 @@ const TextMode = 2;
|
|
|
12995
13010
|
|
|
12996
13011
|
function layoutChar(drawData, style, width, _height) {
|
|
12997
13012
|
const {rows: rows} = drawData;
|
|
12998
|
-
const {textAlign: textAlign, paraIndent: paraIndent
|
|
13013
|
+
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
13014
|
+
const useLetter = style.__letterSpacing || style.motionText;
|
|
12999
13015
|
const justifyLast = width && textAlign.includes("both");
|
|
13000
13016
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
13001
13017
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -13008,8 +13024,8 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
13008
13024
|
remainingWidth = width - row.width - indentWidth;
|
|
13009
13025
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
13010
13026
|
}
|
|
13011
|
-
mode =
|
|
13012
|
-
if (row.isOverflow && !
|
|
13027
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
13028
|
+
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
13013
13029
|
if (mode === TextMode) {
|
|
13014
13030
|
row.x += indentWidth;
|
|
13015
13031
|
toTextChar$1(row);
|
|
@@ -13210,6 +13226,7 @@ function getDrawData$1(content, style) {
|
|
|
13210
13226
|
let width = style.__getInput("width") || 0;
|
|
13211
13227
|
let height = style.__getInput("height") || 0;
|
|
13212
13228
|
const {__padding: padding} = style;
|
|
13229
|
+
if (style.motionText) width = height = 0;
|
|
13213
13230
|
if (padding) {
|
|
13214
13231
|
if (width) x = padding[left$3], width -= padding[right$3] + padding[left$3], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left$3];
|
|
13215
13232
|
if (height) y = padding[top$2], height -= padding[top$2] + padding[bottom$2], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top$2];
|
|
@@ -13783,17 +13800,16 @@ const {topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bot
|
|
|
13783
13800
|
const {toPoint: toPoint} = AroundHelper, {within: within$3, sign: sign$1} = MathHelper, {abs: abs$4} = Math;
|
|
13784
13801
|
|
|
13785
13802
|
const EditDataHelper = {
|
|
13786
|
-
getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode
|
|
13803
|
+
getScaleData(target, startBounds, direction, totalMoveOrScale, lockRatio, around, flipable, scaleMode) {
|
|
13787
13804
|
let align, origin = {}, scaleX = 1, scaleY = 1, lockScale;
|
|
13788
13805
|
const {widthRange: widthRange, heightRange: heightRange, dragBounds: dragBounds, worldTransform: worldTransform, boxBounds: boxBounds} = target;
|
|
13789
13806
|
const {width: width, height: height} = startBounds, worldScaleX = abs$4(worldTransform.scaleX), worldScaleY = abs$4(worldTransform.scaleY);
|
|
13790
|
-
const innerBounds = target.getBounds(boundsType, "inner");
|
|
13791
13807
|
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
13792
13808
|
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
13793
13809
|
const signX = sign$1(originChangedScaleX);
|
|
13794
13810
|
const signY = sign$1(originChangedScaleY);
|
|
13795
|
-
const changedScaleX = scaleMode ? originChangedScaleX : signX *
|
|
13796
|
-
const changedScaleY = scaleMode ? originChangedScaleY : signY *
|
|
13811
|
+
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
13812
|
+
const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
|
|
13797
13813
|
if (isNumber(totalMoveOrScale)) {
|
|
13798
13814
|
scaleX = scaleY = Math.sqrt(totalMoveOrScale);
|
|
13799
13815
|
} else {
|
|
@@ -13878,11 +13894,10 @@ const EditDataHelper = {
|
|
|
13878
13894
|
if (useScaleX) scaleX /= changedScaleX;
|
|
13879
13895
|
if (useScaleY) scaleY /= changedScaleY;
|
|
13880
13896
|
if (!flipable) {
|
|
13881
|
-
if (scaleX < 0) scaleX = 1 /
|
|
13882
|
-
if (scaleY < 0) scaleY = 1 /
|
|
13897
|
+
if (scaleX < 0) scaleX = 1 / boxBounds.width / worldScaleX;
|
|
13898
|
+
if (scaleY < 0) scaleY = 1 / boxBounds.height / worldScaleY;
|
|
13883
13899
|
}
|
|
13884
|
-
toPoint(around || align,
|
|
13885
|
-
this.checkOrigin(target, origin, boundsType);
|
|
13900
|
+
toPoint(around || align, boxBounds, origin, true);
|
|
13886
13901
|
if (dragBounds) {
|
|
13887
13902
|
const scaleData = {
|
|
13888
13903
|
x: scaleX,
|
|
@@ -13893,19 +13908,15 @@ const EditDataHelper = {
|
|
|
13893
13908
|
scaleY = scaleData.y;
|
|
13894
13909
|
}
|
|
13895
13910
|
if (useScaleX && widthRange) {
|
|
13896
|
-
const nowWidth =
|
|
13911
|
+
const nowWidth = boxBounds.width * target.scaleX;
|
|
13897
13912
|
scaleX = within$3(nowWidth * scaleX, widthRange) / nowWidth;
|
|
13898
13913
|
}
|
|
13899
13914
|
if (useScaleY && heightRange) {
|
|
13900
|
-
const nowHeight =
|
|
13915
|
+
const nowHeight = boxBounds.height * target.scaleY;
|
|
13901
13916
|
scaleY = within$3(nowHeight * scaleY, heightRange) / nowHeight;
|
|
13902
13917
|
}
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
minWidth += (innerBounds.width - boxBounds.width) * worldScaleX;
|
|
13906
|
-
minHeight += (innerBounds.height - boxBounds.height) * worldScaleY;
|
|
13907
|
-
}
|
|
13908
|
-
const worldWidth = worldScaleX * innerBounds.width, worldHeight = worldScaleY * innerBounds.height;
|
|
13918
|
+
const minWidth = 1, minHeight = 1;
|
|
13919
|
+
const worldWidth = worldScaleX * boxBounds.width, worldHeight = worldScaleY * boxBounds.height;
|
|
13909
13920
|
if (useScaleX && abs$4(scaleX * worldWidth) < minWidth) scaleX = sign$1(scaleX) * minWidth / worldWidth;
|
|
13910
13921
|
if (useScaleY && abs$4(scaleY * worldHeight) < minHeight) scaleY = sign$1(scaleY) * minHeight / worldHeight;
|
|
13911
13922
|
if (lockRatio && scaleX !== scaleY) {
|
|
@@ -13924,7 +13935,7 @@ const EditDataHelper = {
|
|
|
13924
13935
|
around: around
|
|
13925
13936
|
};
|
|
13926
13937
|
},
|
|
13927
|
-
getRotateData(target, direction, current, last, around
|
|
13938
|
+
getRotateData(target, direction, current, last, around) {
|
|
13928
13939
|
let align, origin = {};
|
|
13929
13940
|
switch (direction) {
|
|
13930
13941
|
case topLeft$1:
|
|
@@ -13946,14 +13957,13 @@ const EditDataHelper = {
|
|
|
13946
13957
|
default:
|
|
13947
13958
|
align = "center";
|
|
13948
13959
|
}
|
|
13949
|
-
toPoint(around || align, target.
|
|
13950
|
-
this.checkOrigin(target, origin, boundsType);
|
|
13960
|
+
toPoint(around || align, target.boxBounds, origin, true);
|
|
13951
13961
|
return {
|
|
13952
13962
|
origin: origin,
|
|
13953
13963
|
rotation: PointHelper.getRotation(last, target.getWorldPointByBox(origin), current)
|
|
13954
13964
|
};
|
|
13955
13965
|
},
|
|
13956
|
-
getSkewData(target, direction, move, around
|
|
13966
|
+
getSkewData(target, direction, move, around) {
|
|
13957
13967
|
let align, origin = {}, skewX = 0, skewY = 0;
|
|
13958
13968
|
let last;
|
|
13959
13969
|
switch (direction) {
|
|
@@ -13996,12 +14006,10 @@ const EditDataHelper = {
|
|
|
13996
14006
|
align = "left";
|
|
13997
14007
|
skewY = 1;
|
|
13998
14008
|
}
|
|
13999
|
-
const
|
|
14000
|
-
const {width: width, height: height} = innerBounds;
|
|
14009
|
+
const {boxBounds: boxBounds} = target, {width: width, height: height} = boxBounds;
|
|
14001
14010
|
last.x = last.x * width;
|
|
14002
14011
|
last.y = last.y * height;
|
|
14003
|
-
toPoint(around || align,
|
|
14004
|
-
this.checkOrigin(target, origin, boundsType);
|
|
14012
|
+
toPoint(around || align, boxBounds, origin, true);
|
|
14005
14013
|
const rotation = PointHelper.getRotation(last, origin, {
|
|
14006
14014
|
x: last.x + (skewX ? move.x : 0),
|
|
14007
14015
|
y: last.y + (skewY ? move.y : 0)
|
|
@@ -14013,13 +14021,6 @@ const EditDataHelper = {
|
|
|
14013
14021
|
skewY: skewY
|
|
14014
14022
|
};
|
|
14015
14023
|
},
|
|
14016
|
-
checkOrigin(target, origin, boundsType) {
|
|
14017
|
-
if (boundsType !== "box") {
|
|
14018
|
-
const {boxBounds: boxBounds} = target, innerBounds = target.getBounds(boundsType, "inner");
|
|
14019
|
-
origin.x += innerBounds.x - boxBounds.x;
|
|
14020
|
-
origin.y += innerBounds.y - boxBounds.y;
|
|
14021
|
-
}
|
|
14022
|
-
},
|
|
14023
14024
|
getAround(around, altKey) {
|
|
14024
14025
|
return altKey && !around ? "center" : around;
|
|
14025
14026
|
},
|
|
@@ -14314,9 +14315,14 @@ class EditBox extends Group {
|
|
|
14314
14315
|
if (this.app) this.rect.syncEventer = this.app.interaction.bottomList = null;
|
|
14315
14316
|
}
|
|
14316
14317
|
updateBounds(bounds) {
|
|
14317
|
-
const {editor: editor, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
|
|
14318
|
+
const {editor: editor, target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
|
|
14318
14319
|
const {editMask: editMask} = editor;
|
|
14319
14320
|
const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, editBoxType: editBoxType, mask: mask, dimOthers: dimOthers, bright: bright, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
|
|
14321
|
+
if (editBoxType === "stroke") {
|
|
14322
|
+
const {scaleX: scaleX, scaleY: scaleY} = target.worldTransform, {strokeBoxSpread: strokeBoxSpread} = target.__layout;
|
|
14323
|
+
strokeBoxSpread && BoundsHelper.spread(bounds, [ strokeBoxSpread * Math.abs(scaleY), strokeBoxSpread * Math.abs(scaleX) ]);
|
|
14324
|
+
}
|
|
14325
|
+
if (spread) BoundsHelper.spread(bounds, spread);
|
|
14320
14326
|
editMask.visible = mask ? true : 0;
|
|
14321
14327
|
if (!isUndefined(dimOthers) || !isUndefined(bright)) {
|
|
14322
14328
|
editor.setDimOthers(dimOthers);
|
|
@@ -14325,8 +14331,6 @@ class EditBox extends Group {
|
|
|
14325
14331
|
} else if (editor.hasDimOthers) {
|
|
14326
14332
|
editor.cancelDimOthers();
|
|
14327
14333
|
}
|
|
14328
|
-
if (editBoxType === "stroke") BoundsHelper.spread(bounds, this.target.__layout.strokeBoxSpread);
|
|
14329
|
-
if (spread) BoundsHelper.spread(bounds, spread);
|
|
14330
14334
|
if (this.view.worldOpacity) {
|
|
14331
14335
|
const {width: width, height: height} = bounds;
|
|
14332
14336
|
const smallSize = isNumber(hideOnSmall) ? hideOnSmall : 10;
|
|
@@ -14463,7 +14467,7 @@ class EditBox extends Group {
|
|
|
14463
14467
|
this.dragPoint = null;
|
|
14464
14468
|
}
|
|
14465
14469
|
onTransformStart(e) {
|
|
14466
|
-
const {hideOnMove: hideOnMove
|
|
14470
|
+
const {hideOnMove: hideOnMove} = this.mergedConfig;
|
|
14467
14471
|
if (this.moving || this.gesturing) this.editor.opacity = hideOnMove ? 0 : 1;
|
|
14468
14472
|
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
|
|
14469
14473
|
const {dragStartData: dragStartData, target: target} = this;
|
|
@@ -14474,7 +14478,7 @@ class EditBox extends Group {
|
|
|
14474
14478
|
x: target.x,
|
|
14475
14479
|
y: target.y
|
|
14476
14480
|
};
|
|
14477
|
-
dragStartData.bounds = Object.assign({}, target.getLayoutBounds(
|
|
14481
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
|
|
14478
14482
|
dragStartData.rotation = target.rotation;
|
|
14479
14483
|
}
|
|
14480
14484
|
onTransformEnd(e) {
|
|
@@ -14847,6 +14851,9 @@ function registerEditTool() {
|
|
|
14847
14851
|
const registerInnerEditor = registerEditTool;
|
|
14848
14852
|
|
|
14849
14853
|
const EditToolCreator = {
|
|
14854
|
+
EditTool: "EditTool",
|
|
14855
|
+
LineEditTool: "LineEditTool",
|
|
14856
|
+
PointsEditTool: "PointsEditTool",
|
|
14850
14857
|
list: {},
|
|
14851
14858
|
register(EditTool, name) {
|
|
14852
14859
|
const {tag: tag} = EditTool.prototype;
|
|
@@ -15038,7 +15045,7 @@ class TransformTool {
|
|
|
15038
15045
|
}
|
|
15039
15046
|
onScale(e) {
|
|
15040
15047
|
const {target: target, mergeConfig: mergeConfig, single: single, dragStartData: dragStartData} = this.editBox;
|
|
15041
|
-
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize
|
|
15048
|
+
let {around: around, lockRatio: lockRatio, flipable: flipable, editSize: editSize} = mergeConfig, totalMove;
|
|
15042
15049
|
if (e instanceof ZoomEvent) {
|
|
15043
15050
|
if (!around) around = target.getBoxPoint(e);
|
|
15044
15051
|
totalMove = e.totalScale;
|
|
@@ -15047,7 +15054,7 @@ class TransformTool {
|
|
|
15047
15054
|
}
|
|
15048
15055
|
const {direction: direction} = e.current;
|
|
15049
15056
|
if (e.shiftKey || target.lockRatio) lockRatio = true;
|
|
15050
|
-
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale"
|
|
15057
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === "scale");
|
|
15051
15058
|
const targetX = target.x, targetY = target.y;
|
|
15052
15059
|
if (e instanceof DragEvent && this.editTool && this.editTool.onScaleWithDrag) {
|
|
15053
15060
|
data.drag = e;
|
|
@@ -15059,7 +15066,7 @@ class TransformTool {
|
|
|
15059
15066
|
}
|
|
15060
15067
|
onRotate(e) {
|
|
15061
15068
|
const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
|
|
15062
|
-
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey
|
|
15069
|
+
const {around: around, rotateAround: rotateAround, rotateGap: rotateGap, diagonalRotateKey: diagonalRotateKey} = mergeConfig;
|
|
15063
15070
|
const {direction: direction} = e.current;
|
|
15064
15071
|
let origin, rotation;
|
|
15065
15072
|
if (e instanceof RotateEvent) {
|
|
@@ -15067,7 +15074,7 @@ class TransformTool {
|
|
|
15067
15074
|
origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
|
|
15068
15075
|
} else {
|
|
15069
15076
|
const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey;
|
|
15070
|
-
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center"
|
|
15077
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : rotateAround || target.around || target.origin || around || "center");
|
|
15071
15078
|
rotation = dragStartData.rotation + data.rotation - target.rotation;
|
|
15072
15079
|
origin = data.origin;
|
|
15073
15080
|
}
|
|
@@ -15079,8 +15086,8 @@ class TransformTool {
|
|
|
15079
15086
|
}
|
|
15080
15087
|
onSkew(e) {
|
|
15081
15088
|
const {target: target, mergeConfig: mergeConfig} = this.editBox;
|
|
15082
|
-
const {around: around
|
|
15083
|
-
const {origin: origin, skewX: skewX, skewY: skewY} = EditDataHelper.getSkewData(target, e.current.direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey)
|
|
15089
|
+
const {around: around} = mergeConfig;
|
|
15090
|
+
const {origin: origin, skewX: skewX, skewY: skewY} = EditDataHelper.getSkewData(target, e.current.direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey));
|
|
15084
15091
|
if (!skewX && !skewY) return;
|
|
15085
15092
|
this.skewOf(origin, skewX, skewY);
|
|
15086
15093
|
}
|
|
@@ -15141,7 +15148,7 @@ class TransformTool {
|
|
|
15141
15148
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
15142
15149
|
if (!this.checkTransform("resizeable")) return;
|
|
15143
15150
|
const {target: target, mergeConfig: mergeConfig, single: single, editor: editor} = this.editBox;
|
|
15144
|
-
const {beforeScale: beforeScale
|
|
15151
|
+
const {beforeScale: beforeScale} = mergeConfig;
|
|
15145
15152
|
if (beforeScale) {
|
|
15146
15153
|
const check = beforeScale({
|
|
15147
15154
|
target: target,
|
|
@@ -15159,8 +15166,7 @@ class TransformTool {
|
|
|
15159
15166
|
worldOrigin: worldOrigin,
|
|
15160
15167
|
scaleX: scaleX,
|
|
15161
15168
|
scaleY: scaleY,
|
|
15162
|
-
transform: transform
|
|
15163
|
-
editBoxType: editBoxType
|
|
15169
|
+
transform: transform
|
|
15164
15170
|
};
|
|
15165
15171
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
15166
15172
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
@@ -15188,7 +15194,7 @@ class TransformTool {
|
|
|
15188
15194
|
rotateOf(origin, rotation) {
|
|
15189
15195
|
if (!this.checkTransform("rotateable")) return;
|
|
15190
15196
|
const {target: target, mergeConfig: mergeConfig, single: single, editor: editor} = this.editBox;
|
|
15191
|
-
const {beforeRotate: beforeRotate
|
|
15197
|
+
const {beforeRotate: beforeRotate} = mergeConfig;
|
|
15192
15198
|
if (beforeRotate) {
|
|
15193
15199
|
const check = beforeRotate({
|
|
15194
15200
|
target: target,
|
|
@@ -15204,8 +15210,7 @@ class TransformTool {
|
|
|
15204
15210
|
editor: editor,
|
|
15205
15211
|
worldOrigin: worldOrigin,
|
|
15206
15212
|
rotation: rotation,
|
|
15207
|
-
transform: transform
|
|
15208
|
-
editBoxType: editBoxType
|
|
15213
|
+
transform: transform
|
|
15209
15214
|
};
|
|
15210
15215
|
this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
|
|
15211
15216
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
|
|
@@ -15215,7 +15220,7 @@ class TransformTool {
|
|
|
15215
15220
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
15216
15221
|
if (!this.checkTransform("skewable")) return;
|
|
15217
15222
|
const {target: target, mergeConfig: mergeConfig, single: single, editor: editor} = this.editBox;
|
|
15218
|
-
const {beforeSkew: beforeSkew
|
|
15223
|
+
const {beforeSkew: beforeSkew} = mergeConfig;
|
|
15219
15224
|
if (beforeSkew) {
|
|
15220
15225
|
const check = beforeSkew({
|
|
15221
15226
|
target: target,
|
|
@@ -15233,8 +15238,7 @@ class TransformTool {
|
|
|
15233
15238
|
worldOrigin: worldOrigin,
|
|
15234
15239
|
skewX: skewX,
|
|
15235
15240
|
skewY: skewY,
|
|
15236
|
-
transform: transform
|
|
15237
|
-
editBoxType: editBoxType
|
|
15241
|
+
transform: transform
|
|
15238
15242
|
};
|
|
15239
15243
|
this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
|
|
15240
15244
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
|
|
@@ -15690,32 +15694,32 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
15690
15694
|
app.unlockLayout();
|
|
15691
15695
|
}
|
|
15692
15696
|
onScale(e) {
|
|
15693
|
-
const {scaleX: scaleX, scaleY: scaleY, transform: transform, worldOrigin: worldOrigin, editor: editor
|
|
15697
|
+
const {scaleX: scaleX, scaleY: scaleY, transform: transform, worldOrigin: worldOrigin, editor: editor} = e;
|
|
15694
15698
|
const {app: app, list: list} = editor;
|
|
15695
15699
|
app.lockLayout();
|
|
15696
15700
|
list.forEach(target => {
|
|
15697
15701
|
const resize = editor.getEditSize(target) !== "scale";
|
|
15698
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
15702
|
+
if (transform) target.transformWorld(transform, resize, false); else target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize, false);
|
|
15699
15703
|
});
|
|
15700
15704
|
app.unlockLayout();
|
|
15701
15705
|
}
|
|
15702
15706
|
onRotate(e) {
|
|
15703
|
-
const {rotation: rotation, transform: transform, worldOrigin: worldOrigin, editor: editor
|
|
15707
|
+
const {rotation: rotation, transform: transform, worldOrigin: worldOrigin, editor: editor} = e;
|
|
15704
15708
|
const {app: app, list: list} = editor;
|
|
15705
15709
|
app.lockLayout();
|
|
15706
15710
|
list.forEach(target => {
|
|
15707
15711
|
const resize = editor.getEditSize(target) !== "scale";
|
|
15708
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
15712
|
+
if (transform) target.transformWorld(transform, resize, false); else target.rotateOfWorld(worldOrigin, rotation);
|
|
15709
15713
|
});
|
|
15710
15714
|
app.unlockLayout();
|
|
15711
15715
|
}
|
|
15712
15716
|
onSkew(e) {
|
|
15713
|
-
const {skewX: skewX, skewY: skewY, transform: transform, worldOrigin: worldOrigin, editor: editor
|
|
15717
|
+
const {skewX: skewX, skewY: skewY, transform: transform, worldOrigin: worldOrigin, editor: editor} = e;
|
|
15714
15718
|
const {app: app, list: list} = editor;
|
|
15715
15719
|
app.lockLayout();
|
|
15716
15720
|
list.forEach(target => {
|
|
15717
15721
|
const resize = editor.getEditSize(target) !== "scale";
|
|
15718
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
15722
|
+
if (transform) target.transformWorld(transform, resize, false); else target.skewOfWorld(worldOrigin, skewX, skewY, resize);
|
|
15719
15723
|
});
|
|
15720
15724
|
app.unlockLayout();
|
|
15721
15725
|
}
|
|
@@ -16115,8 +16119,10 @@ UI.addAttr("editConfig", undefined, dataType);
|
|
|
16115
16119
|
|
|
16116
16120
|
UI.addAttr("editOuter", ui => {
|
|
16117
16121
|
ui.updateLayout();
|
|
16118
|
-
const
|
|
16119
|
-
|
|
16122
|
+
const {EditTool: EditTool, LineEditTool: LineEditTool, PointsEditTool: PointsEditTool} = EditToolCreator;
|
|
16123
|
+
const name = ui.pathInputed || ui.isPointsMode ? PointsEditTool : ui.tag + "EditTool";
|
|
16124
|
+
const hasTool = EditToolCreator.list[name];
|
|
16125
|
+
return ui.__.__isLinePath && !(name == PointsEditTool && hasTool) ? LineEditTool : hasTool ? name : EditTool;
|
|
16120
16126
|
}, dataType);
|
|
16121
16127
|
|
|
16122
16128
|
UI.addAttr("editInner", "PathEditor", dataType);
|
|
@@ -19115,7 +19121,7 @@ const HighCurveHelper = {
|
|
|
19115
19121
|
},
|
|
19116
19122
|
getMotionPathData(data) {
|
|
19117
19123
|
let total = 0, distance, segments = [];
|
|
19118
|
-
let i = 0, x = 0, y = 0, toX, toY, command;
|
|
19124
|
+
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
19119
19125
|
const len = data.length;
|
|
19120
19126
|
while (i < len) {
|
|
19121
19127
|
command = data[i];
|
|
@@ -19140,6 +19146,7 @@ const HighCurveHelper = {
|
|
|
19140
19146
|
break;
|
|
19141
19147
|
|
|
19142
19148
|
case Z$1:
|
|
19149
|
+
closed = true;
|
|
19143
19150
|
i += 1;
|
|
19144
19151
|
|
|
19145
19152
|
default:
|
|
@@ -19151,13 +19158,16 @@ const HighCurveHelper = {
|
|
|
19151
19158
|
return {
|
|
19152
19159
|
total: total,
|
|
19153
19160
|
segments: segments,
|
|
19154
|
-
data: data
|
|
19161
|
+
data: data,
|
|
19162
|
+
closed: closed
|
|
19155
19163
|
};
|
|
19156
19164
|
},
|
|
19157
|
-
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
19158
|
-
const {segments: segments, data: data} = distanceData;
|
|
19159
|
-
motionDistance = UnitConvert.number(motionDistance,
|
|
19160
|
-
|
|
19165
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision, offsetX) {
|
|
19166
|
+
const {segments: segments, data: data, total: total} = distanceData;
|
|
19167
|
+
motionDistance = UnitConvert.number(motionDistance, total);
|
|
19168
|
+
if (offsetX) motionDistance += offsetX;
|
|
19169
|
+
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
19170
|
+
let nowDistance = 0, distance, to = {};
|
|
19161
19171
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
19162
19172
|
let x1, y1, x2, y2, t;
|
|
19163
19173
|
const len = data.length;
|
|
@@ -19169,15 +19179,20 @@ const HighCurveHelper = {
|
|
|
19169
19179
|
toX = data[i + 1];
|
|
19170
19180
|
toY = data[i + 2];
|
|
19171
19181
|
distance = segments[index];
|
|
19172
|
-
if (
|
|
19173
|
-
if (!i) x = toX, y = toY;
|
|
19174
|
-
tempFrom.x = x;
|
|
19175
|
-
tempFrom.y = y;
|
|
19182
|
+
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
19176
19183
|
to.x = toX;
|
|
19177
19184
|
to.y = toY;
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19185
|
+
if (i) {
|
|
19186
|
+
tempFrom.x = x;
|
|
19187
|
+
tempFrom.y = y;
|
|
19188
|
+
PointHelper.getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
19189
|
+
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
19190
|
+
return to;
|
|
19191
|
+
} else {
|
|
19192
|
+
const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
|
|
19193
|
+
to.rotation = nextPoint.rotation;
|
|
19194
|
+
return to;
|
|
19195
|
+
}
|
|
19181
19196
|
}
|
|
19182
19197
|
x = toX;
|
|
19183
19198
|
y = toY;
|
|
@@ -19188,9 +19203,9 @@ const HighCurveHelper = {
|
|
|
19188
19203
|
toX = data[i + 5];
|
|
19189
19204
|
toY = data[i + 6];
|
|
19190
19205
|
distance = segments[index];
|
|
19191
|
-
if (
|
|
19206
|
+
if (nowDistance + distance >= motionDistance) {
|
|
19192
19207
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
19193
|
-
t = HighBezierHelper.getT(motionDistance -
|
|
19208
|
+
t = HighBezierHelper.getT(motionDistance - nowDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
19194
19209
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
19195
19210
|
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
19196
19211
|
return to;
|
|
@@ -19207,7 +19222,7 @@ const HighCurveHelper = {
|
|
|
19207
19222
|
distance = 0;
|
|
19208
19223
|
}
|
|
19209
19224
|
index++;
|
|
19210
|
-
|
|
19225
|
+
nowDistance += distance;
|
|
19211
19226
|
}
|
|
19212
19227
|
return to;
|
|
19213
19228
|
},
|
|
@@ -19306,26 +19321,57 @@ const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix} = LeafHelpe
|
|
|
19306
19321
|
|
|
19307
19322
|
const {updateBounds: updateBounds} = BranchHelper;
|
|
19308
19323
|
|
|
19324
|
+
const {toVertical: toVertical} = PointHelper;
|
|
19325
|
+
|
|
19309
19326
|
UI.addAttr("motionPath", undefined, motionPathType);
|
|
19310
19327
|
|
|
19311
19328
|
UI.addAttr("motionPrecision", 1, motionPathType);
|
|
19312
19329
|
|
|
19313
19330
|
UI.addAttr("motion", undefined, motionPathType);
|
|
19314
19331
|
|
|
19332
|
+
UI.addAttr("motionVertical", "below", motionPathType);
|
|
19333
|
+
|
|
19315
19334
|
UI.addAttr("motionRotation", true, motionPathType);
|
|
19316
19335
|
|
|
19336
|
+
ui$2.getMotionPath = function() {
|
|
19337
|
+
return getMotionPath(this);
|
|
19338
|
+
};
|
|
19339
|
+
|
|
19317
19340
|
ui$2.getMotionPathData = function() {
|
|
19318
19341
|
return getMotionPathData(getMotionPath(this));
|
|
19319
19342
|
};
|
|
19320
19343
|
|
|
19321
|
-
ui$2.
|
|
19322
|
-
|
|
19323
|
-
|
|
19344
|
+
ui$2.getMotionContentHeight = function() {
|
|
19345
|
+
return this.__layout.boxBounds.height;
|
|
19346
|
+
};
|
|
19347
|
+
|
|
19348
|
+
ui$2.getMotionPoint = function(motionDistance, motionVertical, pathElement, offsetX = 0, offsetY = 0) {
|
|
19349
|
+
if (!pathElement) pathElement = getMotionPath(this);
|
|
19350
|
+
const data = getMotionPathData(pathElement);
|
|
19324
19351
|
if (!data.total) return {};
|
|
19325
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance,
|
|
19326
|
-
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
19352
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
|
|
19327
19353
|
const {motionRotation: motionRotation} = this;
|
|
19328
|
-
if (
|
|
19354
|
+
if (isNumber(motionRotation)) point.rotation += motionRotation;
|
|
19355
|
+
let verticalType, verticalOffset;
|
|
19356
|
+
if (isObject(motionVertical)) verticalType = motionVertical.type, verticalOffset = motionVertical.offset; else if (isNumber(motionVertical)) verticalOffset = motionVertical; else verticalType = motionVertical;
|
|
19357
|
+
if (verticalType !== "below" || offsetY) {
|
|
19358
|
+
const {rotation: rotation} = point, height = this.getMotionContentHeight();
|
|
19359
|
+
if (verticalOffset) offsetY += verticalType === "above" ? -verticalOffset : verticalOffset;
|
|
19360
|
+
switch (verticalType) {
|
|
19361
|
+
case "above":
|
|
19362
|
+
toVertical(point, rotation, -height + offsetY);
|
|
19363
|
+
break;
|
|
19364
|
+
|
|
19365
|
+
case "center":
|
|
19366
|
+
toVertical(point, rotation, -height / 2 + offsetY);
|
|
19367
|
+
break;
|
|
19368
|
+
|
|
19369
|
+
case "below":
|
|
19370
|
+
default:
|
|
19371
|
+
toVertical(point, rotation, offsetY);
|
|
19372
|
+
}
|
|
19373
|
+
}
|
|
19374
|
+
MatrixHelper.toOuterPoint(pathElement.localTransform, point);
|
|
19329
19375
|
return point;
|
|
19330
19376
|
};
|
|
19331
19377
|
|
|
@@ -19357,7 +19403,11 @@ function updateMotion(leaf) {
|
|
|
19357
19403
|
const data = getMotionPathData(leaf);
|
|
19358
19404
|
if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
19359
19405
|
} else {
|
|
19360
|
-
leaf.
|
|
19406
|
+
if (leaf.motionText) leaf.__updateMotionText(); else {
|
|
19407
|
+
const point = leaf.getMotionPoint(motion);
|
|
19408
|
+
if (leaf.motionRotation === false) delete point.rotation;
|
|
19409
|
+
leaf.set(point);
|
|
19410
|
+
}
|
|
19361
19411
|
if (!leaf.__hasAutoLayout) {
|
|
19362
19412
|
if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf); else updateMatrix(leaf);
|
|
19363
19413
|
}
|
|
@@ -19379,7 +19429,8 @@ function getMotionPath(leaf) {
|
|
|
19379
19429
|
function getMotionPathData(leaf) {
|
|
19380
19430
|
const data = leaf.__;
|
|
19381
19431
|
if (data.__pathForMotion) return data.__pathForMotion;
|
|
19382
|
-
|
|
19432
|
+
const path = data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
|
|
19433
|
+
return path;
|
|
19383
19434
|
}
|
|
19384
19435
|
|
|
19385
19436
|
function stateType(defaultValue, styleName) {
|