@antv/g-lite 1.0.15 → 1.0.16
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/Canvas.d.ts +7 -0
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/css/parser/path.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyPath.d.ts +2 -3
- package/dist/css/properties/CSSPropertyPath.d.ts.map +1 -1
- package/dist/display-objects/Path.d.ts +0 -2
- package/dist/display-objects/Path.d.ts.map +1 -1
- package/dist/dom/Element.d.ts +5 -1
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/index.esm.js +276 -105
- package/dist/index.js +276 -105
- package/dist/index.umd.js +283 -110
- package/dist/index.umd.min.js +2 -2
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/path.d.ts +1 -1
- package/dist/utils/path.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -5342,11 +5342,16 @@
|
|
|
5342
5342
|
return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
|
|
5343
5343
|
}
|
|
5344
5344
|
|
|
5345
|
+
var toString = {}.toString;
|
|
5346
|
+
var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
|
|
5347
|
+
|
|
5345
5348
|
/**
|
|
5346
|
-
*
|
|
5349
|
+
* 是否为函数
|
|
5350
|
+
* @param {*} fn 对象
|
|
5351
|
+
* @return {Boolean} 是否函数
|
|
5347
5352
|
*/
|
|
5348
5353
|
var isFunction = (function (value) {
|
|
5349
|
-
return
|
|
5354
|
+
return isType(value, 'Function');
|
|
5350
5355
|
});
|
|
5351
5356
|
|
|
5352
5357
|
// isFinite,
|
|
@@ -5358,9 +5363,6 @@
|
|
|
5358
5363
|
return value === null || value === undefined;
|
|
5359
5364
|
};
|
|
5360
5365
|
|
|
5361
|
-
var toString = {}.toString;
|
|
5362
|
-
var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
|
|
5363
|
-
|
|
5364
5366
|
var isArray = (function (value) {
|
|
5365
5367
|
return Array.isArray ? Array.isArray(value) : isType(value, 'Array');
|
|
5366
5368
|
});
|
|
@@ -6069,6 +6071,7 @@
|
|
|
6069
6071
|
|
|
6070
6072
|
var ERROR_MSG_METHOD_NOT_IMPLEMENTED = 'Method not implemented.';
|
|
6071
6073
|
var ERROR_MSG_USE_DOCUMENT_ELEMENT = 'Use document.documentElement instead.';
|
|
6074
|
+
var ERROR_MSG_APPEND_DESTROYED_ELEMENT = 'Cannot append a destroyed element.';
|
|
6072
6075
|
|
|
6073
6076
|
// borrow from hammer.js
|
|
6074
6077
|
var MOUSE_POINTER_ID = 1;
|
|
@@ -10082,9 +10085,8 @@
|
|
|
10082
10085
|
segments: [],
|
|
10083
10086
|
polygons: [],
|
|
10084
10087
|
polylines: [],
|
|
10085
|
-
curve:
|
|
10088
|
+
curve: null,
|
|
10086
10089
|
totalLength: 0,
|
|
10087
|
-
zCommandIndexes: [],
|
|
10088
10090
|
rect: {
|
|
10089
10091
|
x: 0,
|
|
10090
10092
|
y: 0,
|
|
@@ -10107,13 +10109,7 @@
|
|
|
10107
10109
|
|
|
10108
10110
|
var _extractPolygons = extractPolygons(absolutePath),
|
|
10109
10111
|
polygons = _extractPolygons.polygons,
|
|
10110
|
-
polylines = _extractPolygons.polylines; //
|
|
10111
|
-
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
var _path2Curve = path2Curve(absolutePath, true),
|
|
10115
|
-
curve = _path2Curve[0],
|
|
10116
|
-
zCommandIndexes = _path2Curve[1]; // for later use
|
|
10112
|
+
polylines = _extractPolygons.polylines; // for later use
|
|
10117
10113
|
|
|
10118
10114
|
|
|
10119
10115
|
var segments = path2Segments(absolutePath); // Only calculate bbox here since we don't need length now.
|
|
@@ -10130,10 +10126,9 @@
|
|
|
10130
10126
|
segments: segments,
|
|
10131
10127
|
polygons: polygons,
|
|
10132
10128
|
polylines: polylines,
|
|
10133
|
-
|
|
10129
|
+
// curve,
|
|
10134
10130
|
// Delay the calculation of length.
|
|
10135
10131
|
totalLength: 0,
|
|
10136
|
-
zCommandIndexes: zCommandIndexes,
|
|
10137
10132
|
rect: {
|
|
10138
10133
|
x: Number.isFinite(x) ? x : 0,
|
|
10139
10134
|
y: Number.isFinite(y) ? y : 0,
|
|
@@ -10157,6 +10152,19 @@
|
|
|
10157
10152
|
function mergePaths(left, right, object) {
|
|
10158
10153
|
var curve1 = left.curve;
|
|
10159
10154
|
var curve2 = right.curve;
|
|
10155
|
+
|
|
10156
|
+
if (!curve1 || curve1.length === 0) {
|
|
10157
|
+
// convert to curves to do morphing & picking later
|
|
10158
|
+
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
10159
|
+
curve1 = path2Curve(left.absolutePath, false);
|
|
10160
|
+
left.curve = curve1;
|
|
10161
|
+
}
|
|
10162
|
+
|
|
10163
|
+
if (!curve2 || curve2.length === 0) {
|
|
10164
|
+
curve2 = path2Curve(right.absolutePath, false);
|
|
10165
|
+
right.curve = curve2;
|
|
10166
|
+
}
|
|
10167
|
+
|
|
10160
10168
|
var curves = [curve1, curve2];
|
|
10161
10169
|
|
|
10162
10170
|
if (curve1.length !== curve2.length) {
|
|
@@ -12298,9 +12306,8 @@
|
|
|
12298
12306
|
segments: [],
|
|
12299
12307
|
polygons: [],
|
|
12300
12308
|
polylines: [],
|
|
12301
|
-
curve:
|
|
12309
|
+
curve: null,
|
|
12302
12310
|
totalLength: 0,
|
|
12303
|
-
zCommandIndexes: [],
|
|
12304
12311
|
rect: new Rectangle(0, 0, 0, 0)
|
|
12305
12312
|
};
|
|
12306
12313
|
}
|
|
@@ -13583,6 +13590,118 @@
|
|
|
13583
13590
|
return [center[0] + (center[0] - point[0]), center[1] + (center[1] - point[1])];
|
|
13584
13591
|
}
|
|
13585
13592
|
|
|
13593
|
+
var angleBetween$1 = function angleBetween(v0, v1) {
|
|
13594
|
+
var p = v0.x * v1.x + v0.y * v1.y;
|
|
13595
|
+
var n = Math.sqrt((Math.pow(v0.x, 2) + Math.pow(v0.y, 2)) * (Math.pow(v1.x, 2) + Math.pow(v1.y, 2)));
|
|
13596
|
+
var sign = v0.x * v1.y - v0.y * v1.x < 0 ? -1 : 1;
|
|
13597
|
+
var angle = sign * Math.acos(p / n);
|
|
13598
|
+
return angle;
|
|
13599
|
+
};
|
|
13600
|
+
/**
|
|
13601
|
+
* @see https://github.com/rveciana/svg-path-properties/blob/b6bd9a322966f6ef7a311872d80c56e3718de861/src/arc.ts#L121
|
|
13602
|
+
*/
|
|
13603
|
+
|
|
13604
|
+
|
|
13605
|
+
var pointOnEllipticalArc = function pointOnEllipticalArc(p0, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, p1, t) {
|
|
13606
|
+
// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
|
|
13607
|
+
rx = Math.abs(rx);
|
|
13608
|
+
ry = Math.abs(ry);
|
|
13609
|
+
xAxisRotation = mod(xAxisRotation, 360);
|
|
13610
|
+
var xAxisRotationRadians = deg2rad(xAxisRotation); // If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
|
|
13611
|
+
|
|
13612
|
+
if (p0.x === p1.x && p0.y === p1.y) {
|
|
13613
|
+
return {
|
|
13614
|
+
x: p0.x,
|
|
13615
|
+
y: p0.y,
|
|
13616
|
+
ellipticalArcAngle: 0
|
|
13617
|
+
}; // Check if angle is correct
|
|
13618
|
+
} // If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
|
|
13619
|
+
|
|
13620
|
+
|
|
13621
|
+
if (rx === 0 || ry === 0) {
|
|
13622
|
+
//return this.pointOnLine(p0, p1, t);
|
|
13623
|
+
return {
|
|
13624
|
+
x: 0,
|
|
13625
|
+
y: 0,
|
|
13626
|
+
ellipticalArcAngle: 0
|
|
13627
|
+
}; // Check if angle is correct
|
|
13628
|
+
} // Following "Conversion from endpoint to center parameterization"
|
|
13629
|
+
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
|
|
13630
|
+
// Step #1: Compute transformedPoint
|
|
13631
|
+
|
|
13632
|
+
|
|
13633
|
+
var dx = (p0.x - p1.x) / 2;
|
|
13634
|
+
var dy = (p0.y - p1.y) / 2;
|
|
13635
|
+
var transformedPoint = {
|
|
13636
|
+
x: Math.cos(xAxisRotationRadians) * dx + Math.sin(xAxisRotationRadians) * dy,
|
|
13637
|
+
y: -Math.sin(xAxisRotationRadians) * dx + Math.cos(xAxisRotationRadians) * dy
|
|
13638
|
+
}; // Ensure radii are large enough
|
|
13639
|
+
|
|
13640
|
+
var radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
|
|
13641
|
+
|
|
13642
|
+
if (radiiCheck > 1) {
|
|
13643
|
+
rx = Math.sqrt(radiiCheck) * rx;
|
|
13644
|
+
ry = Math.sqrt(radiiCheck) * ry;
|
|
13645
|
+
} // Step #2: Compute transformedCenter
|
|
13646
|
+
|
|
13647
|
+
|
|
13648
|
+
var cSquareNumerator = Math.pow(rx, 2) * Math.pow(ry, 2) - Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) - Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
|
|
13649
|
+
var cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
|
|
13650
|
+
var cRadicand = cSquareNumerator / cSquareRootDenom; // Make sure this never drops below zero because of precision
|
|
13651
|
+
|
|
13652
|
+
cRadicand = cRadicand < 0 ? 0 : cRadicand;
|
|
13653
|
+
var cCoef = (largeArcFlag !== sweepFlag ? 1 : -1) * Math.sqrt(cRadicand);
|
|
13654
|
+
var transformedCenter = {
|
|
13655
|
+
x: cCoef * (rx * transformedPoint.y / ry),
|
|
13656
|
+
y: cCoef * (-(ry * transformedPoint.x) / rx)
|
|
13657
|
+
}; // Step #3: Compute center
|
|
13658
|
+
|
|
13659
|
+
var center = {
|
|
13660
|
+
x: Math.cos(xAxisRotationRadians) * transformedCenter.x - Math.sin(xAxisRotationRadians) * transformedCenter.y + (p0.x + p1.x) / 2,
|
|
13661
|
+
y: Math.sin(xAxisRotationRadians) * transformedCenter.x + Math.cos(xAxisRotationRadians) * transformedCenter.y + (p0.y + p1.y) / 2
|
|
13662
|
+
}; // Step #4: Compute start/sweep angles
|
|
13663
|
+
// Start angle of the elliptical arc prior to the stretch and rotate operations.
|
|
13664
|
+
// Difference between the start and end angles
|
|
13665
|
+
|
|
13666
|
+
var startVector = {
|
|
13667
|
+
x: (transformedPoint.x - transformedCenter.x) / rx,
|
|
13668
|
+
y: (transformedPoint.y - transformedCenter.y) / ry
|
|
13669
|
+
};
|
|
13670
|
+
var startAngle = angleBetween$1({
|
|
13671
|
+
x: 1,
|
|
13672
|
+
y: 0
|
|
13673
|
+
}, startVector);
|
|
13674
|
+
var endVector = {
|
|
13675
|
+
x: (-transformedPoint.x - transformedCenter.x) / rx,
|
|
13676
|
+
y: (-transformedPoint.y - transformedCenter.y) / ry
|
|
13677
|
+
};
|
|
13678
|
+
var sweepAngle = angleBetween$1(startVector, endVector);
|
|
13679
|
+
|
|
13680
|
+
if (!sweepFlag && sweepAngle > 0) {
|
|
13681
|
+
sweepAngle -= 2 * Math.PI;
|
|
13682
|
+
} else if (sweepFlag && sweepAngle < 0) {
|
|
13683
|
+
sweepAngle += 2 * Math.PI;
|
|
13684
|
+
} // We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
|
|
13685
|
+
|
|
13686
|
+
|
|
13687
|
+
sweepAngle %= 2 * Math.PI; // From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
|
|
13688
|
+
|
|
13689
|
+
var angle = startAngle + sweepAngle * t;
|
|
13690
|
+
var ellipseComponentX = rx * Math.cos(angle);
|
|
13691
|
+
var ellipseComponentY = ry * Math.sin(angle);
|
|
13692
|
+
var point = {
|
|
13693
|
+
x: Math.cos(xAxisRotationRadians) * ellipseComponentX - Math.sin(xAxisRotationRadians) * ellipseComponentY + center.x,
|
|
13694
|
+
y: Math.sin(xAxisRotationRadians) * ellipseComponentX + Math.cos(xAxisRotationRadians) * ellipseComponentY + center.y,
|
|
13695
|
+
ellipticalArcStartAngle: startAngle,
|
|
13696
|
+
ellipticalArcEndAngle: startAngle + sweepAngle,
|
|
13697
|
+
ellipticalArcAngle: angle,
|
|
13698
|
+
ellipticalArcCenter: center,
|
|
13699
|
+
resultantRx: rx,
|
|
13700
|
+
resultantRy: ry
|
|
13701
|
+
};
|
|
13702
|
+
return point;
|
|
13703
|
+
};
|
|
13704
|
+
|
|
13586
13705
|
function path2Segments(path) {
|
|
13587
13706
|
var segments = [];
|
|
13588
13707
|
var currentPoint = null; // 当前图形
|
|
@@ -13608,7 +13727,8 @@
|
|
|
13608
13727
|
endTangent: null,
|
|
13609
13728
|
currentPoint: null,
|
|
13610
13729
|
nextPoint: null,
|
|
13611
|
-
arcParams: null
|
|
13730
|
+
arcParams: null,
|
|
13731
|
+
box: null
|
|
13612
13732
|
};
|
|
13613
13733
|
|
|
13614
13734
|
switch (command) {
|
|
@@ -13712,42 +13832,64 @@
|
|
|
13712
13832
|
segment.endTangent = [currentPoint[0] - _cp3[0], currentPoint[1] - _cp3[1]];
|
|
13713
13833
|
}
|
|
13714
13834
|
} else if (command === 'A') {
|
|
13715
|
-
var
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
_ref$rx = _ref.rx,
|
|
13723
|
-
rx = _ref$rx === void 0 ? 0 : _ref$rx,
|
|
13724
|
-
_ref$ry = _ref.ry,
|
|
13725
|
-
ry = _ref$ry === void 0 ? 0 : _ref$ry,
|
|
13726
|
-
_ref$sweepFlag = _ref.sweepFlag,
|
|
13727
|
-
sweepFlag = _ref$sweepFlag === void 0 ? 0 : _ref$sweepFlag,
|
|
13728
|
-
_ref$startAngle = _ref.startAngle,
|
|
13729
|
-
startAngle = _ref$startAngle === void 0 ? 0 : _ref$startAngle,
|
|
13730
|
-
_ref$endAngle = _ref.endAngle,
|
|
13731
|
-
endAngle = _ref$endAngle === void 0 ? 0 : _ref$endAngle;
|
|
13732
|
-
|
|
13733
|
-
if (sweepFlag === 0) {
|
|
13734
|
-
d *= -1;
|
|
13735
|
-
}
|
|
13835
|
+
var _getTangentAtRatio = getTangentAtRatio(segment, 0),
|
|
13836
|
+
dx1 = _getTangentAtRatio.x,
|
|
13837
|
+
dy1 = _getTangentAtRatio.y;
|
|
13838
|
+
|
|
13839
|
+
var _getTangentAtRatio2 = getTangentAtRatio(segment, 1, false),
|
|
13840
|
+
dx2 = _getTangentAtRatio2.x,
|
|
13841
|
+
dy2 = _getTangentAtRatio2.y;
|
|
13736
13842
|
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
segment.startTangent = [dx1 - startMovePoint[0], dy1 - startMovePoint[1]];
|
|
13740
|
-
var dx2 = rx * Math.cos(startAngle + endAngle + d) + cx;
|
|
13741
|
-
var dy2 = ry * Math.sin(startAngle + endAngle - d) + cy;
|
|
13742
|
-
segment.endTangent = [prePoint[0] - dx2, prePoint[1] - dy2];
|
|
13843
|
+
segment.startTangent = [dx1, dy1];
|
|
13844
|
+
segment.endTangent = [dx2, dy2];
|
|
13743
13845
|
}
|
|
13744
13846
|
|
|
13745
13847
|
segments.push(segment);
|
|
13746
13848
|
}
|
|
13747
13849
|
|
|
13748
13850
|
return segments;
|
|
13851
|
+
}
|
|
13852
|
+
/**
|
|
13853
|
+
* Use length instead of ratio
|
|
13854
|
+
*/
|
|
13855
|
+
|
|
13856
|
+
function getTangentAtRatio(segment, ratio, sign) {
|
|
13857
|
+
if (sign === void 0) {
|
|
13858
|
+
sign = true;
|
|
13859
|
+
}
|
|
13860
|
+
|
|
13861
|
+
var _segment$arcParams = segment.arcParams,
|
|
13862
|
+
_segment$arcParams$rx = _segment$arcParams.rx,
|
|
13863
|
+
rx = _segment$arcParams$rx === void 0 ? 0 : _segment$arcParams$rx,
|
|
13864
|
+
_segment$arcParams$ry = _segment$arcParams.ry,
|
|
13865
|
+
ry = _segment$arcParams$ry === void 0 ? 0 : _segment$arcParams$ry,
|
|
13866
|
+
xRotation = _segment$arcParams.xRotation,
|
|
13867
|
+
arcFlag = _segment$arcParams.arcFlag,
|
|
13868
|
+
sweepFlag = _segment$arcParams.sweepFlag;
|
|
13869
|
+
var p1 = pointOnEllipticalArc({
|
|
13870
|
+
x: segment.prePoint[0],
|
|
13871
|
+
y: segment.prePoint[1]
|
|
13872
|
+
}, rx, ry, xRotation, !!arcFlag, !!sweepFlag, {
|
|
13873
|
+
x: segment.currentPoint[0],
|
|
13874
|
+
y: segment.currentPoint[1]
|
|
13875
|
+
}, ratio);
|
|
13876
|
+
var p2 = pointOnEllipticalArc({
|
|
13877
|
+
x: segment.prePoint[0],
|
|
13878
|
+
y: segment.prePoint[1]
|
|
13879
|
+
}, rx, ry, xRotation, !!arcFlag, !!sweepFlag, {
|
|
13880
|
+
x: segment.currentPoint[0],
|
|
13881
|
+
y: segment.currentPoint[1]
|
|
13882
|
+
}, sign ? ratio + 0.005 : ratio - 0.005);
|
|
13883
|
+
var xDist = p2.x - p1.x;
|
|
13884
|
+
var yDist = p2.y - p1.y;
|
|
13885
|
+
var dist = Math.sqrt(xDist * xDist + yDist * yDist);
|
|
13886
|
+
return {
|
|
13887
|
+
x: -xDist / dist,
|
|
13888
|
+
y: -yDist / dist
|
|
13889
|
+
};
|
|
13749
13890
|
} // 向量长度
|
|
13750
13891
|
|
|
13892
|
+
|
|
13751
13893
|
function vMag(v) {
|
|
13752
13894
|
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
|
13753
13895
|
} // u.v/|u||v|,计算夹角的余弦值
|
|
@@ -13879,6 +14021,17 @@
|
|
|
13879
14021
|
}
|
|
13880
14022
|
|
|
13881
14023
|
path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "," + cur[5] + "," + c[0] + "," + c[1];
|
|
14024
|
+
} else if (cur[0] === 'Q') {
|
|
14025
|
+
var _p = fromValues$2(cur[1] - defX, cur[2] - defY, 0);
|
|
14026
|
+
|
|
14027
|
+
var _p2 = fromValues$2(cur[3] - defX, cur[4] - defY, 0);
|
|
14028
|
+
|
|
14029
|
+
if (transform) {
|
|
14030
|
+
transformMat4(_p, _p, transform);
|
|
14031
|
+
transformMat4(_p2, _p2, transform);
|
|
14032
|
+
}
|
|
14033
|
+
|
|
14034
|
+
path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "}";
|
|
13882
14035
|
}
|
|
13883
14036
|
|
|
13884
14037
|
return prev += path;
|
|
@@ -13998,13 +14151,8 @@
|
|
|
13998
14151
|
break;
|
|
13999
14152
|
|
|
14000
14153
|
case exports.Shape.PATH:
|
|
14001
|
-
var
|
|
14002
|
-
|
|
14003
|
-
zCommandIndexes = _object$parsedStyle$p.zCommandIndexes;
|
|
14004
|
-
commands = [].concat(curve);
|
|
14005
|
-
zCommandIndexes.forEach(function (zIndex, index) {
|
|
14006
|
-
commands.splice(zIndex + index + 1, 0, ['Z']);
|
|
14007
|
-
});
|
|
14154
|
+
var absolutePath = object.parsedStyle.path.absolutePath;
|
|
14155
|
+
commands = [].concat(absolutePath);
|
|
14008
14156
|
break;
|
|
14009
14157
|
}
|
|
14010
14158
|
|
|
@@ -14012,7 +14160,7 @@
|
|
|
14012
14160
|
return commandsToPathString(commands, object, transform);
|
|
14013
14161
|
}
|
|
14014
14162
|
}
|
|
14015
|
-
function translatePathToString(
|
|
14163
|
+
function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
|
|
14016
14164
|
if (startOffsetX === void 0) {
|
|
14017
14165
|
startOffsetX = 0;
|
|
14018
14166
|
}
|
|
@@ -14029,27 +14177,32 @@
|
|
|
14029
14177
|
endOffsetY = 0;
|
|
14030
14178
|
}
|
|
14031
14179
|
|
|
14032
|
-
var newValue =
|
|
14180
|
+
var newValue = absolutePath.map(function (params, i) {
|
|
14033
14181
|
var command = params[0];
|
|
14034
|
-
var
|
|
14035
|
-
var
|
|
14036
|
-
var
|
|
14182
|
+
var nextSegment = absolutePath[i + 1];
|
|
14183
|
+
var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0;
|
|
14184
|
+
var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0;
|
|
14037
14185
|
|
|
14038
14186
|
switch (command) {
|
|
14039
14187
|
case 'M':
|
|
14040
|
-
|
|
14188
|
+
// Use start marker offset
|
|
14189
|
+
if (useStartOffset) {
|
|
14190
|
+
return "M " + (params[1] - defX + startOffsetX) + "," + (params[2] - defY + startOffsetY) + " L " + (params[1] - defX) + "," + (params[2] - defY);
|
|
14191
|
+
} else {
|
|
14192
|
+
return "M " + (params[1] - defX) + "," + (params[2] - defY);
|
|
14193
|
+
}
|
|
14041
14194
|
|
|
14042
14195
|
case 'L':
|
|
14043
|
-
return "L " + (params[1] -
|
|
14196
|
+
return "L " + (params[1] - defX + (useEndOffset ? endOffsetX : 0)) + "," + (params[2] - defY + (useEndOffset ? endOffsetY : 0));
|
|
14044
14197
|
|
|
14045
14198
|
case 'Q':
|
|
14046
|
-
return "Q " + (params[1] -
|
|
14199
|
+
return "Q " + (params[1] - defX) + " " + (params[2] - defY) + "," + (params[3] - defX) + " " + (params[4] - defY) + (useEndOffset ? " L " + (params[3] - defX + endOffsetX) + "," + (params[4] - defY + endOffsetY) : '');
|
|
14047
14200
|
|
|
14048
14201
|
case 'C':
|
|
14049
|
-
return "C " + (params[1] -
|
|
14202
|
+
return "C " + (params[1] - defX) + " " + (params[2] - defY) + "," + (params[3] - defX) + " " + (params[4] - defY) + "," + (params[5] - defX) + " " + (params[6] - defY) + (useEndOffset ? " L " + (params[5] - defX + endOffsetX) + "," + (params[6] - defY + endOffsetY) : '');
|
|
14050
14203
|
|
|
14051
14204
|
case 'A':
|
|
14052
|
-
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] -
|
|
14205
|
+
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - defX) + " " + (params[7] - defY) + (useEndOffset ? " L " + (params[6] - defX + endOffsetX) + "," + (params[7] - defY + endOffsetY) : '');
|
|
14053
14206
|
|
|
14054
14207
|
case 'Z':
|
|
14055
14208
|
return 'Z';
|
|
@@ -17946,6 +18099,10 @@
|
|
|
17946
18099
|
_proto.appendChild = function appendChild(child, index) {
|
|
17947
18100
|
var _this$ownerDocument;
|
|
17948
18101
|
|
|
18102
|
+
if (child.destroyed) {
|
|
18103
|
+
throw new Error(ERROR_MSG_APPEND_DESTROYED_ELEMENT);
|
|
18104
|
+
}
|
|
18105
|
+
|
|
17949
18106
|
runtime.sceneGraphService.attach(child, this, index);
|
|
17950
18107
|
|
|
17951
18108
|
if ((_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.defaultView) {
|
|
@@ -17991,7 +18148,7 @@
|
|
|
17991
18148
|
return child;
|
|
17992
18149
|
}
|
|
17993
18150
|
/**
|
|
17994
|
-
* Remove all children
|
|
18151
|
+
* Remove all children which can be appended to its original parent later again.
|
|
17995
18152
|
*/
|
|
17996
18153
|
;
|
|
17997
18154
|
|
|
@@ -18000,7 +18157,16 @@
|
|
|
18000
18157
|
|
|
18001
18158
|
this.childNodes.slice().forEach(function (child) {
|
|
18002
18159
|
_this2.removeChild(child);
|
|
18160
|
+
});
|
|
18161
|
+
}
|
|
18162
|
+
/**
|
|
18163
|
+
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
18164
|
+
*/
|
|
18165
|
+
;
|
|
18003
18166
|
|
|
18167
|
+
_proto.destroyChildren = function destroyChildren() {
|
|
18168
|
+
this.childNodes.slice().forEach(function (child) {
|
|
18169
|
+
child.destroyChildren();
|
|
18004
18170
|
child.destroy();
|
|
18005
18171
|
});
|
|
18006
18172
|
}
|
|
@@ -20171,7 +20337,6 @@
|
|
|
20171
20337
|
});
|
|
20172
20338
|
|
|
20173
20339
|
if (marker && marker instanceof DisplayObject) {
|
|
20174
|
-
// FIXME: should use original path instead of parsed curve
|
|
20175
20340
|
for (var i = 1; i < segments.length - 1; i++) {
|
|
20176
20341
|
var _segments$i$currentPo = segments[i].currentPoint,
|
|
20177
20342
|
ox = _segments$i$currentPo[0],
|
|
@@ -25934,10 +26099,22 @@
|
|
|
25934
26099
|
|
|
25935
26100
|
_proto.removeChild = function removeChild(child) {
|
|
25936
26101
|
return this.document.documentElement.removeChild(child);
|
|
25937
|
-
}
|
|
26102
|
+
}
|
|
26103
|
+
/**
|
|
26104
|
+
* Remove all children which can be appended to its original parent later again.
|
|
26105
|
+
*/
|
|
26106
|
+
;
|
|
25938
26107
|
|
|
25939
26108
|
_proto.removeChildren = function removeChildren() {
|
|
25940
26109
|
this.document.documentElement.removeChildren();
|
|
26110
|
+
}
|
|
26111
|
+
/**
|
|
26112
|
+
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
26113
|
+
*/
|
|
26114
|
+
;
|
|
26115
|
+
|
|
26116
|
+
_proto.destroyChildren = function destroyChildren() {
|
|
26117
|
+
this.document.documentElement.destroyChildren();
|
|
25941
26118
|
};
|
|
25942
26119
|
|
|
25943
26120
|
_proto.render = function render() {
|
|
@@ -26094,37 +26271,32 @@
|
|
|
26094
26271
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
26095
26272
|
var _this5 = this;
|
|
26096
26273
|
|
|
26097
|
-
|
|
26098
|
-
|
|
26099
|
-
|
|
26100
|
-
|
|
26101
|
-
path.push(child);
|
|
26102
|
-
}
|
|
26103
|
-
}); // unmount from leaf to root
|
|
26274
|
+
// unmountChildren recursively
|
|
26275
|
+
parent.childNodes.forEach(function (child) {
|
|
26276
|
+
_this5.unmountChildren(child);
|
|
26277
|
+
});
|
|
26104
26278
|
|
|
26105
|
-
|
|
26106
|
-
|
|
26107
|
-
|
|
26108
|
-
|
|
26109
|
-
|
|
26110
|
-
|
|
26111
|
-
|
|
26279
|
+
if (this.inited) {
|
|
26280
|
+
if (parent.isMutationObserved) {
|
|
26281
|
+
parent.dispatchEvent(unmountedEvent);
|
|
26282
|
+
} else {
|
|
26283
|
+
unmountedEvent.target = parent;
|
|
26284
|
+
this.dispatchEvent(unmountedEvent, true);
|
|
26285
|
+
} // skip document.documentElement
|
|
26112
26286
|
|
|
26113
|
-
if (child.isMutationObserved) {
|
|
26114
|
-
child.dispatchEvent(unmountedEvent);
|
|
26115
|
-
} else {
|
|
26116
|
-
unmountedEvent.target = child;
|
|
26117
26287
|
|
|
26118
|
-
|
|
26119
|
-
|
|
26288
|
+
if (parent !== this.document.documentElement) {
|
|
26289
|
+
parent.ownerDocument = null;
|
|
26290
|
+
}
|
|
26120
26291
|
|
|
26292
|
+
parent.isConnected = false;
|
|
26293
|
+
} // trigger after unmounted
|
|
26121
26294
|
|
|
26122
|
-
if (child !== _this5.document.documentElement) {
|
|
26123
|
-
child.ownerDocument = null;
|
|
26124
|
-
}
|
|
26125
26295
|
|
|
26126
|
-
|
|
26127
|
-
|
|
26296
|
+
if (parent.isCustomElement) {
|
|
26297
|
+
if (parent.disconnectedCallback) {
|
|
26298
|
+
parent.disconnectedCallback();
|
|
26299
|
+
}
|
|
26128
26300
|
}
|
|
26129
26301
|
};
|
|
26130
26302
|
|
|
@@ -26132,29 +26304,30 @@
|
|
|
26132
26304
|
var _this6 = this;
|
|
26133
26305
|
|
|
26134
26306
|
if (this.inited) {
|
|
26135
|
-
parent.
|
|
26136
|
-
|
|
26137
|
-
|
|
26138
|
-
child.isConnected = true;
|
|
26139
|
-
|
|
26140
|
-
if (child.isMutationObserved) {
|
|
26141
|
-
child.dispatchEvent(mountedEvent);
|
|
26142
|
-
} else {
|
|
26143
|
-
mountedEvent.target = child;
|
|
26307
|
+
if (!parent.isConnected) {
|
|
26308
|
+
parent.ownerDocument = this.document;
|
|
26309
|
+
parent.isConnected = true;
|
|
26144
26310
|
|
|
26145
|
-
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
|
|
26149
|
-
|
|
26150
|
-
if (child.connectedCallback) {
|
|
26151
|
-
child.connectedCallback();
|
|
26152
|
-
}
|
|
26153
|
-
}
|
|
26311
|
+
if (parent.isMutationObserved) {
|
|
26312
|
+
parent.dispatchEvent(mountedEvent);
|
|
26313
|
+
} else {
|
|
26314
|
+
mountedEvent.target = parent;
|
|
26315
|
+
this.dispatchEvent(mountedEvent, true);
|
|
26154
26316
|
}
|
|
26155
|
-
}
|
|
26317
|
+
}
|
|
26156
26318
|
} else {
|
|
26157
26319
|
console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', parent.nodeName);
|
|
26320
|
+
} // recursively mount children
|
|
26321
|
+
|
|
26322
|
+
|
|
26323
|
+
parent.childNodes.forEach(function (child) {
|
|
26324
|
+
_this6.mountChildren(child);
|
|
26325
|
+
}); // trigger after mounted
|
|
26326
|
+
|
|
26327
|
+
if (parent.isCustomElement) {
|
|
26328
|
+
if (parent.connectedCallback) {
|
|
26329
|
+
parent.connectedCallback();
|
|
26330
|
+
}
|
|
26158
26331
|
}
|
|
26159
26332
|
};
|
|
26160
26333
|
|