@antv/g 5.0.23 → 5.1.1
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/index.umd.min.js +3 -2
- package/es/AbstractRenderer.d.ts +11 -0
- package/es/AbstractRenderer.js +17 -2
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +2 -0
- package/es/components/Geometry.d.ts +0 -4
- package/es/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +5 -1
- package/es/css/CSSProperty.d.ts +2 -1
- package/es/css/StyleValueRegistry.d.ts +2 -1
- package/es/css/StyleValueRegistry.js +71 -88
- package/es/css/index.d.ts +1 -1
- package/es/css/index.js +1 -1
- package/es/css/layout/FragmentResult.d.ts +32 -0
- package/es/css/layout/FragmentResult.js +32 -0
- package/es/css/layout/LayoutChildren.d.ts +23 -0
- package/es/css/layout/LayoutChildren.js +55 -0
- package/es/css/layout/LayoutContext.d.ts +35 -0
- package/es/css/layout/LayoutContext.js +35 -0
- package/es/css/layout/LayoutDefinition.d.ts +20 -0
- package/es/css/layout/LayoutDefinition.js +9 -0
- package/es/css/layout/LayoutEdges.d.ts +24 -0
- package/es/css/layout/LayoutEdges.js +41 -0
- package/es/css/layout/LayoutEngine.d.ts +41 -0
- package/es/css/layout/LayoutEngine.js +332 -0
- package/es/css/layout/LayoutFragment.d.ts +26 -0
- package/es/css/layout/LayoutFragment.js +28 -0
- package/es/css/layout/LayoutObject.d.ts +46 -0
- package/es/css/layout/LayoutObject.js +172 -0
- package/es/css/layout/LayoutRegistry.d.ts +16 -0
- package/es/css/layout/LayoutRegistry.js +78 -0
- package/es/css/layout/LayoutWorkTask.d.ts +14 -0
- package/es/css/layout/LayoutWorkTask.js +1 -0
- package/es/css/layout/index.d.ts +11 -0
- package/es/css/layout/index.js +11 -0
- package/es/css/layout/types.d.ts +104 -0
- package/es/css/layout/types.js +66 -0
- package/es/css/parser/color.d.ts +1 -1
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.js +5 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +9 -2
- package/es/css/parser/points.d.ts +8 -1
- package/es/css/parser/points.js +33 -3
- package/es/css/parser/transform.js +1 -1
- package/es/css/properties/CSSPropertyClipPath.js +7 -1
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +59 -20
- package/es/css/properties/CSSPropertyPath.d.ts +2 -2
- package/es/css/properties/CSSPropertyPath.js +7 -5
- package/es/css/properties/CSSPropertyPoints.js +3 -4
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- package/es/display-objects/CustomElement.d.ts +6 -2
- package/es/display-objects/CustomElement.js +15 -5
- package/es/display-objects/DisplayObject.d.ts +1 -7
- package/es/display-objects/DisplayObject.js +6 -26
- package/es/display-objects/Ellipse.d.ts +4 -0
- package/es/display-objects/Ellipse.js +2 -0
- package/es/display-objects/Group.d.ts +4 -0
- package/es/display-objects/Group.js +2 -0
- package/es/display-objects/HTML.d.ts +4 -4
- package/es/display-objects/HTML.js +5 -3
- package/es/display-objects/Image.d.ts +4 -0
- package/es/display-objects/Image.js +2 -0
- package/es/display-objects/Line.js +2 -0
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +6 -2
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +2 -0
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +87 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/services/EventService.js +10 -2
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +1 -1
- package/es/services/RenderingService.js +1 -1
- package/es/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +9 -0
- package/es/services/aabb/CircleUpdater.d.ts +0 -2
- package/es/services/aabb/CircleUpdater.js +2 -6
- package/es/services/aabb/EllipseUpdater.d.ts +0 -2
- package/es/services/aabb/EllipseUpdater.js +2 -6
- package/es/services/aabb/LineUpdater.d.ts +0 -2
- package/es/services/aabb/LineUpdater.js +1 -3
- package/es/services/aabb/PathUpdater.d.ts +0 -2
- package/es/services/aabb/PathUpdater.js +1 -5
- package/es/services/aabb/PolylineUpdater.d.ts +0 -2
- package/es/services/aabb/PolylineUpdater.js +1 -3
- package/es/services/aabb/RectUpdater.d.ts +0 -2
- package/es/services/aabb/RectUpdater.js +1 -5
- package/es/services/aabb/TextUpdater.d.ts +7 -0
- package/es/services/aabb/TextUpdater.js +0 -4
- package/es/services/aabb/interfaces.d.ts +0 -3
- package/es/types.d.ts +7 -23
- package/es/types.js +1 -0
- package/es/utils/deferred.d.ts +43 -0
- package/es/utils/deferred.js +117 -0
- package/es/utils/dom.d.ts +2 -0
- package/es/utils/dom.js +8 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -1
- package/es/utils/interpolation.js +2 -8
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +61 -24
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +2 -0
- package/lib/components/Geometry.d.ts +0 -4
- package/lib/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +7 -1
- package/lib/css/CSSProperty.d.ts +2 -1
- package/lib/css/StyleValueRegistry.d.ts +2 -1
- package/lib/css/StyleValueRegistry.js +70 -88
- package/lib/css/index.d.ts +1 -1
- package/lib/css/index.js +12 -12
- package/lib/css/layout/FragmentResult.d.ts +32 -0
- package/lib/css/layout/FragmentResult.js +51 -0
- package/lib/css/layout/LayoutChildren.d.ts +23 -0
- package/lib/css/layout/LayoutChildren.js +72 -0
- package/lib/css/layout/LayoutContext.d.ts +35 -0
- package/lib/css/layout/LayoutContext.js +49 -0
- package/lib/css/layout/LayoutDefinition.d.ts +20 -0
- package/lib/css/layout/LayoutDefinition.js +16 -0
- package/lib/css/layout/LayoutEdges.d.ts +24 -0
- package/lib/css/layout/LayoutEdges.js +56 -0
- package/lib/css/layout/LayoutEngine.d.ts +41 -0
- package/lib/css/layout/LayoutEngine.js +345 -0
- package/lib/css/layout/LayoutFragment.d.ts +26 -0
- package/lib/css/layout/LayoutFragment.js +44 -0
- package/lib/css/layout/LayoutObject.d.ts +46 -0
- package/lib/css/layout/LayoutObject.js +182 -0
- package/lib/css/layout/LayoutRegistry.d.ts +16 -0
- package/lib/css/layout/LayoutRegistry.js +87 -0
- package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
- package/lib/css/layout/LayoutWorkTask.js +5 -0
- package/lib/css/layout/index.d.ts +11 -0
- package/lib/css/layout/index.js +148 -0
- package/lib/css/layout/types.d.ts +104 -0
- package/lib/css/layout/types.js +74 -0
- package/lib/css/parser/color.d.ts +1 -1
- package/lib/css/parser/color.js +1 -1
- package/lib/css/parser/dimension.js +4 -0
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +9 -2
- package/lib/css/parser/points.d.ts +8 -1
- package/lib/css/parser/points.js +33 -3
- package/lib/css/parser/transform.js +1 -1
- package/lib/css/properties/CSSPropertyClipPath.js +8 -1
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +60 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
- package/lib/css/properties/CSSPropertyPath.js +7 -5
- package/lib/css/properties/CSSPropertyPoints.js +3 -4
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- package/lib/display-objects/CustomElement.d.ts +6 -2
- package/lib/display-objects/CustomElement.js +13 -4
- package/lib/display-objects/DisplayObject.d.ts +1 -7
- package/lib/display-objects/DisplayObject.js +6 -27
- package/lib/display-objects/Ellipse.d.ts +4 -0
- package/lib/display-objects/Ellipse.js +2 -0
- package/lib/display-objects/Group.d.ts +4 -0
- package/lib/display-objects/Group.js +2 -0
- package/lib/display-objects/HTML.d.ts +4 -4
- package/lib/display-objects/HTML.js +5 -3
- package/lib/display-objects/Image.d.ts +4 -0
- package/lib/display-objects/Image.js +2 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +6 -2
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +2 -0
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +89 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/services/EventService.js +10 -2
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +1 -1
- package/lib/services/RenderingService.js +1 -1
- package/lib/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +12 -0
- package/lib/services/aabb/CircleUpdater.d.ts +0 -2
- package/lib/services/aabb/CircleUpdater.js +2 -6
- package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
- package/lib/services/aabb/EllipseUpdater.js +2 -6
- package/lib/services/aabb/LineUpdater.d.ts +0 -2
- package/lib/services/aabb/LineUpdater.js +1 -3
- package/lib/services/aabb/PathUpdater.d.ts +0 -2
- package/lib/services/aabb/PathUpdater.js +1 -5
- package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
- package/lib/services/aabb/PolylineUpdater.js +1 -3
- package/lib/services/aabb/RectUpdater.d.ts +0 -2
- package/lib/services/aabb/RectUpdater.js +1 -5
- package/lib/services/aabb/TextUpdater.d.ts +7 -0
- package/lib/services/aabb/TextUpdater.js +0 -4
- package/lib/services/aabb/interfaces.d.ts +0 -3
- package/lib/types.d.ts +7 -23
- package/lib/types.js +1 -0
- package/lib/utils/deferred.d.ts +43 -0
- package/lib/utils/deferred.js +131 -0
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +17 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -0
- package/lib/utils/interpolation.js +2 -8
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +55 -24
- package/package.json +3 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
package/lib/css/parser/path.js
CHANGED
|
@@ -16,7 +16,7 @@ var _path = require("../../utils/path");
|
|
|
16
16
|
|
|
17
17
|
var _Rectangle = require("../../shapes/Rectangle");
|
|
18
18
|
|
|
19
|
-
function parsePath(path) {
|
|
19
|
+
function parsePath(path, object) {
|
|
20
20
|
var absolutePath = (0, _util.path2Absolute)(path);
|
|
21
21
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
22
22
|
var clonedAbsolutePath = absolutePath.slice();
|
|
@@ -37,6 +37,13 @@ function parsePath(path) {
|
|
|
37
37
|
totalLength = _c.totalLength,
|
|
38
38
|
curveSegments = _c.curveSegments;
|
|
39
39
|
|
|
40
|
+
var rect = getPathBBox(curve);
|
|
41
|
+
|
|
42
|
+
if (object) {
|
|
43
|
+
object.parsedStyle.defX = rect.x;
|
|
44
|
+
object.parsedStyle.defY = rect.y;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
return {
|
|
41
48
|
absolutePath: absolutePath,
|
|
42
49
|
hasArc: hasArc,
|
|
@@ -47,7 +54,7 @@ function parsePath(path) {
|
|
|
47
54
|
totalLength: totalLength,
|
|
48
55
|
curveSegments: curveSegments,
|
|
49
56
|
zCommandIndexes: zCommandIndexes,
|
|
50
|
-
rect:
|
|
57
|
+
rect: rect
|
|
51
58
|
};
|
|
52
59
|
}
|
|
53
60
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DisplayObject } from '../..';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* points="100,10 250,150 200,110"
|
|
7
|
+
*/
|
|
8
|
+
export declare function parsePoints(pointsOrStr: string | [number, number][], object: DisplayObject): {
|
|
2
9
|
points: [number, number][];
|
|
3
10
|
totalLength: number;
|
|
4
11
|
segments: [number, number][];
|
package/lib/css/parser/points.js
CHANGED
|
@@ -5,13 +5,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.parsePoints = parsePoints;
|
|
7
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
8
10
|
var _gMath = require("@antv/g-math");
|
|
9
11
|
|
|
10
12
|
var _utils = require("../../utils");
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* points="100,10 250,150 200,110"
|
|
19
|
+
*/
|
|
20
|
+
function parsePoints(pointsOrStr, object) {
|
|
21
|
+
var points;
|
|
22
|
+
|
|
23
|
+
if ((0, _utils.isString)(pointsOrStr)) {
|
|
24
|
+
points = pointsOrStr.split(' ').map(function (pointStr) {
|
|
25
|
+
var _a = (0, _tslib.__read)(pointStr.split(','), 2),
|
|
26
|
+
x = _a[0],
|
|
27
|
+
y = _a[1];
|
|
28
|
+
|
|
29
|
+
return [Number(x), Number(y)];
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
points = pointsOrStr;
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
var segments = [];
|
|
@@ -31,6 +49,18 @@ function parsePoints(points) {
|
|
|
31
49
|
segments.push(segmentT);
|
|
32
50
|
}
|
|
33
51
|
});
|
|
52
|
+
var minX = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(points.map(function (point) {
|
|
53
|
+
return point[0];
|
|
54
|
+
})), false));
|
|
55
|
+
var minY = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(points.map(function (point) {
|
|
56
|
+
return point[1];
|
|
57
|
+
})), false));
|
|
58
|
+
|
|
59
|
+
if (object) {
|
|
60
|
+
object.parsedStyle.defX = minX;
|
|
61
|
+
object.parsedStyle.defY = minY;
|
|
62
|
+
}
|
|
63
|
+
|
|
34
64
|
return {
|
|
35
65
|
points: points,
|
|
36
66
|
totalLength: totalLength,
|
|
@@ -11,6 +11,8 @@ var _manaSyringe = require("mana-syringe");
|
|
|
11
11
|
|
|
12
12
|
var _services = require("../../services");
|
|
13
13
|
|
|
14
|
+
var _cssom = require("../cssom");
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @see /zh/docs/api/basic/display-object#clippath
|
|
16
18
|
* @example
|
|
@@ -34,7 +36,12 @@ function () {
|
|
|
34
36
|
function CSSPropertyClipPath() {}
|
|
35
37
|
|
|
36
38
|
CSSPropertyClipPath.prototype.calculator = function (name, oldClipPath, newClipPath, object) {
|
|
37
|
-
//
|
|
39
|
+
// unset
|
|
40
|
+
if (newClipPath instanceof _cssom.CSSKeywordValue) {
|
|
41
|
+
newClipPath = null;
|
|
42
|
+
} // clear ref to old clip path
|
|
43
|
+
|
|
44
|
+
|
|
38
45
|
if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
|
|
39
46
|
var index = oldClipPath.style.clipPathTargets.indexOf(object);
|
|
40
47
|
oldClipPath.style.clipPathTargets.splice(index, 1);
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import type { DisplayObject } from '../../display-objects';
|
|
2
2
|
import type { CSSProperty } from '../CSSProperty';
|
|
3
3
|
import type { CSSUnitValue } from '../cssom';
|
|
4
|
-
import { mergeDimensions } from '../parser';
|
|
5
4
|
import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
|
|
6
5
|
/**
|
|
7
6
|
* local position
|
|
8
7
|
*/
|
|
9
8
|
export declare class CSSPropertyLocalPosition extends CSSPropertyLengthOrPercentage implements Partial<CSSProperty<CSSUnitValue, CSSUnitValue>> {
|
|
10
|
-
/**
|
|
11
|
-
* <length> & <percentage>
|
|
12
|
-
*/
|
|
13
|
-
parser: (css: string) => CSSUnitValue;
|
|
14
|
-
/**
|
|
15
|
-
* mix between CSS.px(x)
|
|
16
|
-
*/
|
|
17
|
-
mixer: typeof mergeDimensions;
|
|
18
9
|
/**
|
|
19
10
|
* update local position
|
|
20
11
|
*/
|
|
@@ -9,10 +9,12 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
-
var _parser = require("../parser");
|
|
13
|
-
|
|
14
12
|
var _CSSPropertyLengthOrPercentage = require("./CSSPropertyLengthOrPercentage");
|
|
15
13
|
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
|
|
16
|
+
var _types = require("../../types");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* local position
|
|
18
20
|
*/
|
|
@@ -22,19 +24,7 @@ function (_super) {
|
|
|
22
24
|
(0, _tslib.__extends)(CSSPropertyLocalPosition, _super);
|
|
23
25
|
|
|
24
26
|
function CSSPropertyLocalPosition() {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* <length> & <percentage>
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_this.parser = _parser.parseLengthOrPercentage;
|
|
32
|
-
/**
|
|
33
|
-
* mix between CSS.px(x)
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
_this.mixer = _parser.mergeDimensions;
|
|
37
|
-
return _this;
|
|
27
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
38
28
|
}
|
|
39
29
|
/**
|
|
40
30
|
* update local position
|
|
@@ -42,11 +32,61 @@ function (_super) {
|
|
|
42
32
|
|
|
43
33
|
|
|
44
34
|
CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
object.
|
|
35
|
+
var x;
|
|
36
|
+
var y;
|
|
37
|
+
var z;
|
|
38
|
+
|
|
39
|
+
switch (object.nodeName) {
|
|
40
|
+
case _types.Shape.CIRCLE:
|
|
41
|
+
case _types.Shape.ELLIPSE:
|
|
42
|
+
var _a = object.parsedStyle,
|
|
43
|
+
cx = _a.cx,
|
|
44
|
+
cy = _a.cy;
|
|
45
|
+
|
|
46
|
+
if (!(0, _utils.isNil)(cx)) {
|
|
47
|
+
x = cx.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!(0, _utils.isNil)(cy)) {
|
|
51
|
+
y = cy.value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
break;
|
|
55
|
+
|
|
56
|
+
case _types.Shape.LINE:
|
|
57
|
+
var _b = object.parsedStyle,
|
|
58
|
+
x1 = _b.x1,
|
|
59
|
+
x2 = _b.x2,
|
|
60
|
+
y1 = _b.y1,
|
|
61
|
+
y2 = _b.y2;
|
|
62
|
+
var minX = Math.min(x1.value, x2.value);
|
|
63
|
+
var minY = Math.min(y1.value, y2.value);
|
|
64
|
+
x = minX;
|
|
65
|
+
y = minY;
|
|
66
|
+
z = 0;
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
default:
|
|
70
|
+
if (!(0, _utils.isNil)(object.parsedStyle.x)) {
|
|
71
|
+
x = object.parsedStyle.x.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!(0, _utils.isNil)(object.parsedStyle.y)) {
|
|
75
|
+
y = object.parsedStyle.y.value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
object.parsedStyle.defX = x || 0;
|
|
82
|
+
object.parsedStyle.defY = y || 0;
|
|
83
|
+
|
|
84
|
+
var _c = (0, _tslib.__read)(object.getLocalPosition(), 3),
|
|
85
|
+
ox = _c[0],
|
|
86
|
+
oy = _c[1],
|
|
87
|
+
oz = _c[2];
|
|
88
|
+
|
|
89
|
+
object.setLocalPosition((0, _utils.isNil)(x) ? ox : x, (0, _utils.isNil)(y) ? oy : y, (0, _utils.isNil)(z) ? oz : z);
|
|
50
90
|
};
|
|
51
91
|
|
|
52
92
|
CSSPropertyLocalPosition = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyLocalPosition);
|
|
@@ -8,12 +8,12 @@ export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathSt
|
|
|
8
8
|
*/
|
|
9
9
|
parser: typeof parsePath;
|
|
10
10
|
calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
|
|
11
|
-
absolutePath: import("
|
|
11
|
+
absolutePath: import("../..").PathCommand[];
|
|
12
12
|
hasArc: boolean;
|
|
13
13
|
segments: import("../../display-objects").PathSegment[];
|
|
14
14
|
polygons: [number, number][][];
|
|
15
15
|
polylines: [number, number][][];
|
|
16
|
-
curve: import("
|
|
16
|
+
curve: import("../..").PathCommand[];
|
|
17
17
|
totalLength: number;
|
|
18
18
|
curveSegments: number[][];
|
|
19
19
|
zCommandIndexes: number[];
|
|
@@ -27,7 +27,8 @@ function () {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
|
|
30
|
-
|
|
30
|
+
// unset
|
|
31
|
+
if (parsed instanceof _cssom.CSSKeywordValue && parsed.value === 'unset') {
|
|
31
32
|
return {
|
|
32
33
|
absolutePath: [],
|
|
33
34
|
hasArc: false,
|
|
@@ -51,10 +52,11 @@ function () {
|
|
|
51
52
|
|
|
52
53
|
CSSPropertyPath.prototype.postProcessor = function (object) {
|
|
53
54
|
var _a = object.parsedStyle,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
_b = _a.defX,
|
|
56
|
+
defX = _b === void 0 ? 0 : _b,
|
|
57
|
+
_c = _a.defY,
|
|
58
|
+
defY = _c === void 0 ? 0 : _c;
|
|
59
|
+
object.setLocalPosition(defX, defY);
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
CSSPropertyPath = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPath);
|
|
@@ -24,10 +24,9 @@ function () {
|
|
|
24
24
|
|
|
25
25
|
CSSPropertyPoints.prototype.postProcessor = function (object) {
|
|
26
26
|
var _a = object.parsedStyle,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
|
|
27
|
+
defX = _a.defX,
|
|
28
|
+
defY = _a.defY;
|
|
29
|
+
object.setLocalPosition(defX, defY);
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
CSSPropertyPoints = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPoints);
|
|
@@ -34,5 +34,5 @@ import { parseTransform, mergeTransforms } from '../parser';
|
|
|
34
34
|
export declare class CSSPropertyTransform implements Partial<CSSProperty<any[], any[]>> {
|
|
35
35
|
parser: typeof parseTransform;
|
|
36
36
|
mixer: typeof mergeTransforms;
|
|
37
|
-
|
|
37
|
+
postProcessor(object: DisplayObject): void;
|
|
38
38
|
}
|
|
@@ -51,112 +51,84 @@ function () {
|
|
|
51
51
|
this.mixer = _parser.mergeTransforms;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
CSSPropertyTransform.prototype.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// ...(newValue || []).map(({ t }) => t),
|
|
60
|
-
// ]);
|
|
54
|
+
CSSPropertyTransform.prototype.postProcessor = function (object) {
|
|
55
|
+
var _a = object.parsedStyle,
|
|
56
|
+
transform = _a.transform,
|
|
57
|
+
defX = _a.defX,
|
|
58
|
+
defY = _a.defY;
|
|
61
59
|
|
|
60
|
+
if (transform && transform.length) {
|
|
61
|
+
// reset transform
|
|
62
|
+
object.resetLocalTransform();
|
|
63
|
+
object.setLocalPosition(defX, defY);
|
|
64
|
+
transform.forEach(function (_a) {
|
|
65
|
+
var t = _a.t,
|
|
66
|
+
d = _a.d;
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
if (t === 'scale') {
|
|
69
|
+
// scale(1) scale(1, 1)
|
|
70
|
+
var newScale = d.map(function (s) {
|
|
71
|
+
return s.value;
|
|
72
|
+
}) || [1, 1];
|
|
73
|
+
object.scaleLocal(newScale[0], newScale[1], 1);
|
|
74
|
+
} else if (t === 'scalex') {
|
|
75
|
+
var newScale = d.map(function (s) {
|
|
76
|
+
return s.value;
|
|
77
|
+
}) || [1];
|
|
78
|
+
object.scaleLocal(newScale[0], 1, 1);
|
|
79
|
+
} else if (t === 'scaley') {
|
|
80
|
+
var newScale = d.map(function (s) {
|
|
81
|
+
return s.value;
|
|
82
|
+
}) || [1];
|
|
83
|
+
object.scaleLocal(1, newScale[0], 1);
|
|
84
|
+
} else if (t === 'scalez') {
|
|
85
|
+
var newScale = d.map(function (s) {
|
|
86
|
+
return s.value;
|
|
87
|
+
}) || [1];
|
|
88
|
+
object.scaleLocal(1, 1, newScale[0]);
|
|
89
|
+
} else if (t === 'scale3d') {
|
|
90
|
+
var newScale = d.map(function (s) {
|
|
91
|
+
return s.value;
|
|
92
|
+
}) || [1, 1, 1];
|
|
93
|
+
object.scaleLocal(newScale[0], newScale[1], newScale[2]);
|
|
94
|
+
} else if (t === 'translate') {
|
|
95
|
+
var newTranslation = d || [_cssom.Opx, _cssom.Opx];
|
|
96
|
+
object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
|
|
97
|
+
} else if (t === 'translatex') {
|
|
98
|
+
var newTranslation = d || [_cssom.Opx];
|
|
99
|
+
object.translateLocal(newTranslation[0].value, 0, 0);
|
|
100
|
+
} else if (t === 'translatey') {
|
|
101
|
+
var newTranslation = d || [_cssom.Opx];
|
|
102
|
+
object.translateLocal(0, newTranslation[0].value, 0);
|
|
103
|
+
} else if (t === 'translatez') {
|
|
104
|
+
var newTranslation = d || [_cssom.Opx];
|
|
105
|
+
object.translateLocal(0, 0, newTranslation[0].value);
|
|
106
|
+
} else if (t === 'translate3d') {
|
|
107
|
+
var newTranslation = d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
|
|
108
|
+
object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
|
|
109
|
+
} else if (t === 'rotate') {
|
|
110
|
+
var newAngles = d || [_cssom.Odeg];
|
|
111
|
+
object.rotateLocal(0, 0, newAngles[0].value);
|
|
112
|
+
} else if (t === 'rotatex') {
|
|
113
|
+
var newAngles = d || [_cssom.Odeg];
|
|
114
|
+
object.rotateLocal(newAngles[0].value, 0, 0);
|
|
115
|
+
} else if (t === 'rotatey') {
|
|
116
|
+
var newAngles = d || [_cssom.Odeg];
|
|
117
|
+
object.rotateLocal(0, newAngles[0].value, 0);
|
|
118
|
+
} else if (t === 'rotatez') {
|
|
119
|
+
var newAngles = d || [_cssom.Odeg];
|
|
120
|
+
object.rotateLocal(0, 0, newAngles[0].value);
|
|
121
|
+
} else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
|
|
122
|
+
// const newAngles = value && value.d || [Odeg, Odeg, Odeg];
|
|
123
|
+
// const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
|
|
124
|
+
// object.rotateLocal(
|
|
125
|
+
// newAngles[0].value - oldAngles[0].value,
|
|
126
|
+
// newAngles[1].value - oldAngles[1].value,
|
|
127
|
+
// newAngles[2].value - oldAngles[2].value,
|
|
128
|
+
// );
|
|
129
|
+
}
|
|
67
130
|
});
|
|
68
|
-
|
|
69
|
-
return o.t === t;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
if (t === 'scale') {
|
|
73
|
-
// scale(1) scale(1, 1)
|
|
74
|
-
var newScale = value && value.d && value.d.map(function (s) {
|
|
75
|
-
return s.value;
|
|
76
|
-
}) || [1, 1];
|
|
77
|
-
var oldScale = old && old.d && old.d.map(function (s) {
|
|
78
|
-
return s.value;
|
|
79
|
-
}) || [1, 1];
|
|
80
|
-
object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], 1);
|
|
81
|
-
} else if (t === 'scalex') {
|
|
82
|
-
var newScale = value && value.d && value.d.map(function (s) {
|
|
83
|
-
return s.value;
|
|
84
|
-
}) || [1];
|
|
85
|
-
var oldScale = old && old.d && old.d.map(function (s) {
|
|
86
|
-
return s.value;
|
|
87
|
-
}) || [1];
|
|
88
|
-
object.scaleLocal(newScale[0] / oldScale[0], 1, 1);
|
|
89
|
-
} else if (t === 'scaley') {
|
|
90
|
-
var newScale = value && value.d && value.d.map(function (s) {
|
|
91
|
-
return s.value;
|
|
92
|
-
}) || [1];
|
|
93
|
-
var oldScale = old && old.d && old.d.map(function (s) {
|
|
94
|
-
return s.value;
|
|
95
|
-
}) || [1];
|
|
96
|
-
object.scaleLocal(1, newScale[0] / oldScale[0], 1);
|
|
97
|
-
} else if (t === 'scalez') {
|
|
98
|
-
var newScale = value && value.d && value.d.map(function (s) {
|
|
99
|
-
return s.value;
|
|
100
|
-
}) || [1];
|
|
101
|
-
var oldScale = old && old.d && old.d.map(function (s) {
|
|
102
|
-
return s.value;
|
|
103
|
-
}) || [1];
|
|
104
|
-
object.scaleLocal(1, 1, newScale[0] / oldScale[0]);
|
|
105
|
-
} else if (t === 'scale3d') {
|
|
106
|
-
var newScale = value && value.d && value.d.map(function (s) {
|
|
107
|
-
return s.value;
|
|
108
|
-
}) || [1, 1, 1];
|
|
109
|
-
var oldScale = old && old.d && old.d.map(function (s) {
|
|
110
|
-
return s.value;
|
|
111
|
-
}) || [1, 1, 1];
|
|
112
|
-
object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], newScale[2] / oldScale[2]);
|
|
113
|
-
} else if (t === 'translate') {
|
|
114
|
-
var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx];
|
|
115
|
-
var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx];
|
|
116
|
-
object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, 0);
|
|
117
|
-
} else if (t === 'translatex') {
|
|
118
|
-
var newTranslation = value && value.d || [_cssom.Opx];
|
|
119
|
-
var oldTranslation = old && old.d || [_cssom.Opx];
|
|
120
|
-
object.translateLocal(newTranslation[0].value - oldTranslation[0].value, 0, 0);
|
|
121
|
-
} else if (t === 'translatey') {
|
|
122
|
-
var newTranslation = value && value.d || [_cssom.Opx];
|
|
123
|
-
var oldTranslation = old && old.d || [_cssom.Opx];
|
|
124
|
-
object.translateLocal(0, newTranslation[0].value - oldTranslation[0].value, 0);
|
|
125
|
-
} else if (t === 'translatez') {
|
|
126
|
-
var newTranslation = value && value.d || [_cssom.Opx];
|
|
127
|
-
var oldTranslation = old && old.d || [_cssom.Opx];
|
|
128
|
-
object.translateLocal(0, 0, newTranslation[0].value - oldTranslation[0].value);
|
|
129
|
-
} else if (t === 'translate3d') {
|
|
130
|
-
var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
|
|
131
|
-
var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
|
|
132
|
-
object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, newTranslation[2].value - oldTranslation[2].value);
|
|
133
|
-
} else if (t === 'rotate') {
|
|
134
|
-
var newAngles = value && value.d || [_cssom.Odeg];
|
|
135
|
-
var oldAngles = old && old.d || [_cssom.Odeg];
|
|
136
|
-
object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
|
|
137
|
-
} else if (t === 'rotatex') {
|
|
138
|
-
var newAngles = value && value.d || [_cssom.Odeg];
|
|
139
|
-
var oldAngles = old && old.d || [_cssom.Odeg];
|
|
140
|
-
object.rotateLocal(newAngles[0].value - oldAngles[0].value, 0, 0);
|
|
141
|
-
} else if (t === 'rotatey') {
|
|
142
|
-
var newAngles = value && value.d || [_cssom.Odeg];
|
|
143
|
-
var oldAngles = old && old.d || [_cssom.Odeg];
|
|
144
|
-
object.rotateLocal(0, newAngles[0].value - oldAngles[0].value, 0);
|
|
145
|
-
} else if (t === 'rotatez') {
|
|
146
|
-
var newAngles = value && value.d || [_cssom.Odeg];
|
|
147
|
-
var oldAngles = old && old.d || [_cssom.Odeg];
|
|
148
|
-
object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
|
|
149
|
-
} else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
|
|
150
|
-
// const newAngles = value && value.d || [Odeg, Odeg, Odeg];
|
|
151
|
-
// const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
|
|
152
|
-
// object.rotateLocal(
|
|
153
|
-
// newAngles[0].value - oldAngles[0].value,
|
|
154
|
-
// newAngles[1].value - oldAngles[1].value,
|
|
155
|
-
// newAngles[2].value - oldAngles[2].value,
|
|
156
|
-
// );
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return newValue;
|
|
131
|
+
}
|
|
160
132
|
};
|
|
161
133
|
|
|
162
134
|
CSSPropertyTransform = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyTransform);
|
|
@@ -3,9 +3,13 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
import type { CSSUnitValue } from '../css';
|
|
5
5
|
export interface CircleStyleProps extends BaseStyleProps {
|
|
6
|
+
cx?: number | string;
|
|
7
|
+
cy?: number | string;
|
|
6
8
|
r: number | string;
|
|
7
9
|
}
|
|
8
10
|
export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
|
|
11
|
+
cx: CSSUnitValue;
|
|
12
|
+
cy: CSSUnitValue;
|
|
9
13
|
r: CSSUnitValue;
|
|
10
14
|
}
|
|
11
15
|
export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
3
|
import type { BaseStyleProps } from '../types';
|
|
4
|
+
export interface BaseCustomElementStyleProps extends BaseStyleProps {
|
|
5
|
+
x?: number | string;
|
|
6
|
+
y?: number | string;
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
9
|
* shadow root
|
|
6
10
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
7
11
|
*/
|
|
8
|
-
export declare abstract class CustomElement<CustomElementStyleProps extends
|
|
9
|
-
constructor(
|
|
12
|
+
export declare abstract class CustomElement<CustomElementStyleProps extends BaseCustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
13
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<CustomElementStyleProps>);
|
|
10
14
|
/**
|
|
11
15
|
* fired after element insert into DOM tree
|
|
12
16
|
*/
|
|
@@ -20,12 +20,21 @@ var CustomElement =
|
|
|
20
20
|
function (_super) {
|
|
21
21
|
(0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
|
|
22
22
|
|
|
23
|
-
function CustomElement(
|
|
24
|
-
if (
|
|
25
|
-
|
|
23
|
+
function CustomElement(_a) {
|
|
24
|
+
if (_a === void 0) {
|
|
25
|
+
_a = {};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var _this =
|
|
28
|
+
var _this = this;
|
|
29
|
+
|
|
30
|
+
var style = _a.style,
|
|
31
|
+
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
32
|
+
_this = _super.call(this, (0, _tslib.__assign)({
|
|
33
|
+
style: (0, _tslib.__assign)({
|
|
34
|
+
x: '',
|
|
35
|
+
y: ''
|
|
36
|
+
}, style)
|
|
37
|
+
}, rest)) || this;
|
|
29
38
|
|
|
30
39
|
_this.handleMounted = function (e) {
|
|
31
40
|
if (e.target === e.currentTarget) {
|
|
@@ -116,14 +116,8 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
116
116
|
getLocalRotation(): quat;
|
|
117
117
|
getLocalTransform(): mat4;
|
|
118
118
|
getWorldTransform(): mat4;
|
|
119
|
+
setLocalTransform(transform: mat4): this;
|
|
119
120
|
resetLocalTransform(): void;
|
|
120
|
-
/**
|
|
121
|
-
* sync style.x/y when local position changed
|
|
122
|
-
*
|
|
123
|
-
* Mixins may not declare private/protected properties
|
|
124
|
-
* however, you can use ES2020 private fields
|
|
125
|
-
*/
|
|
126
|
-
private syncLocalPosition;
|
|
127
121
|
/**
|
|
128
122
|
* returns an array of all Animation objects affecting this element
|
|
129
123
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|