@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.
Files changed (230) hide show
  1. package/dist/index.umd.min.js +3 -2
  2. package/es/AbstractRenderer.d.ts +11 -0
  3. package/es/AbstractRenderer.js +17 -2
  4. package/es/Canvas.d.ts +1 -1
  5. package/es/Canvas.js +2 -0
  6. package/es/components/Geometry.d.ts +0 -4
  7. package/es/css/CSS.d.ts +2 -1
  8. package/es/css/CSS.js +5 -1
  9. package/es/css/CSSProperty.d.ts +2 -1
  10. package/es/css/StyleValueRegistry.d.ts +2 -1
  11. package/es/css/StyleValueRegistry.js +71 -88
  12. package/es/css/index.d.ts +1 -1
  13. package/es/css/index.js +1 -1
  14. package/es/css/layout/FragmentResult.d.ts +32 -0
  15. package/es/css/layout/FragmentResult.js +32 -0
  16. package/es/css/layout/LayoutChildren.d.ts +23 -0
  17. package/es/css/layout/LayoutChildren.js +55 -0
  18. package/es/css/layout/LayoutContext.d.ts +35 -0
  19. package/es/css/layout/LayoutContext.js +35 -0
  20. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  21. package/es/css/layout/LayoutDefinition.js +9 -0
  22. package/es/css/layout/LayoutEdges.d.ts +24 -0
  23. package/es/css/layout/LayoutEdges.js +41 -0
  24. package/es/css/layout/LayoutEngine.d.ts +41 -0
  25. package/es/css/layout/LayoutEngine.js +332 -0
  26. package/es/css/layout/LayoutFragment.d.ts +26 -0
  27. package/es/css/layout/LayoutFragment.js +28 -0
  28. package/es/css/layout/LayoutObject.d.ts +46 -0
  29. package/es/css/layout/LayoutObject.js +172 -0
  30. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  31. package/es/css/layout/LayoutRegistry.js +78 -0
  32. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  33. package/es/css/layout/LayoutWorkTask.js +1 -0
  34. package/es/css/layout/index.d.ts +11 -0
  35. package/es/css/layout/index.js +11 -0
  36. package/es/css/layout/types.d.ts +104 -0
  37. package/es/css/layout/types.js +66 -0
  38. package/es/css/parser/color.d.ts +1 -1
  39. package/es/css/parser/color.js +2 -2
  40. package/es/css/parser/dimension.js +5 -1
  41. package/es/css/parser/path.d.ts +2 -2
  42. package/es/css/parser/path.js +9 -2
  43. package/es/css/parser/points.d.ts +8 -1
  44. package/es/css/parser/points.js +33 -3
  45. package/es/css/parser/transform.js +1 -1
  46. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  47. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  48. package/es/css/properties/CSSPropertyLocalPosition.js +59 -20
  49. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  50. package/es/css/properties/CSSPropertyPath.js +7 -5
  51. package/es/css/properties/CSSPropertyPoints.js +3 -4
  52. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  53. package/es/css/properties/CSSPropertyTransform.js +76 -104
  54. package/es/display-objects/Circle.d.ts +4 -0
  55. package/es/display-objects/Circle.js +2 -0
  56. package/es/display-objects/CustomElement.d.ts +6 -2
  57. package/es/display-objects/CustomElement.js +15 -5
  58. package/es/display-objects/DisplayObject.d.ts +1 -7
  59. package/es/display-objects/DisplayObject.js +6 -26
  60. package/es/display-objects/Ellipse.d.ts +4 -0
  61. package/es/display-objects/Ellipse.js +2 -0
  62. package/es/display-objects/Group.d.ts +4 -0
  63. package/es/display-objects/Group.js +2 -0
  64. package/es/display-objects/HTML.d.ts +4 -4
  65. package/es/display-objects/HTML.js +5 -3
  66. package/es/display-objects/Image.d.ts +4 -0
  67. package/es/display-objects/Image.js +2 -0
  68. package/es/display-objects/Line.js +2 -0
  69. package/es/display-objects/Path.d.ts +2 -2
  70. package/es/display-objects/Polygon.js +1 -1
  71. package/es/display-objects/Polyline.js +1 -1
  72. package/es/display-objects/Rect.d.ts +6 -2
  73. package/es/display-objects/Rect.js +2 -0
  74. package/es/display-objects/Text.d.ts +4 -0
  75. package/es/display-objects/Text.js +2 -0
  76. package/es/dom/Element.js +1 -0
  77. package/es/global-module.js +87 -1
  78. package/es/index.d.ts +3 -0
  79. package/es/index.js +3 -0
  80. package/es/services/EventService.js +10 -2
  81. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  82. package/es/services/OffscreenCanvasCreator.js +1 -1
  83. package/es/services/RenderingService.d.ts +1 -1
  84. package/es/services/RenderingService.js +1 -1
  85. package/es/services/SceneGraphService.d.ts +2 -0
  86. package/es/services/SceneGraphService.js +9 -0
  87. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  88. package/es/services/aabb/CircleUpdater.js +2 -6
  89. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  90. package/es/services/aabb/EllipseUpdater.js +2 -6
  91. package/es/services/aabb/LineUpdater.d.ts +0 -2
  92. package/es/services/aabb/LineUpdater.js +1 -3
  93. package/es/services/aabb/PathUpdater.d.ts +0 -2
  94. package/es/services/aabb/PathUpdater.js +1 -5
  95. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  96. package/es/services/aabb/PolylineUpdater.js +1 -3
  97. package/es/services/aabb/RectUpdater.d.ts +0 -2
  98. package/es/services/aabb/RectUpdater.js +1 -5
  99. package/es/services/aabb/TextUpdater.d.ts +7 -0
  100. package/es/services/aabb/TextUpdater.js +0 -4
  101. package/es/services/aabb/interfaces.d.ts +0 -3
  102. package/es/types.d.ts +7 -23
  103. package/es/types.js +1 -0
  104. package/es/utils/deferred.d.ts +43 -0
  105. package/es/utils/deferred.js +117 -0
  106. package/es/utils/dom.d.ts +2 -0
  107. package/es/utils/dom.js +8 -0
  108. package/es/utils/index.d.ts +2 -0
  109. package/es/utils/index.js +3 -1
  110. package/es/utils/interpolation.js +2 -8
  111. package/es/utils/math.js +4 -3
  112. package/es/utils/path.d.ts +2 -2
  113. package/es/utils/path.js +61 -24
  114. package/lib/AbstractRenderer.d.ts +11 -0
  115. package/lib/AbstractRenderer.js +17 -2
  116. package/lib/Canvas.d.ts +1 -1
  117. package/lib/Canvas.js +2 -0
  118. package/lib/components/Geometry.d.ts +0 -4
  119. package/lib/css/CSS.d.ts +2 -1
  120. package/lib/css/CSS.js +7 -1
  121. package/lib/css/CSSProperty.d.ts +2 -1
  122. package/lib/css/StyleValueRegistry.d.ts +2 -1
  123. package/lib/css/StyleValueRegistry.js +70 -88
  124. package/lib/css/index.d.ts +1 -1
  125. package/lib/css/index.js +12 -12
  126. package/lib/css/layout/FragmentResult.d.ts +32 -0
  127. package/lib/css/layout/FragmentResult.js +51 -0
  128. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  129. package/lib/css/layout/LayoutChildren.js +72 -0
  130. package/lib/css/layout/LayoutContext.d.ts +35 -0
  131. package/lib/css/layout/LayoutContext.js +49 -0
  132. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  133. package/lib/css/layout/LayoutDefinition.js +16 -0
  134. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  135. package/lib/css/layout/LayoutEdges.js +56 -0
  136. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  137. package/lib/css/layout/LayoutEngine.js +345 -0
  138. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  139. package/lib/css/layout/LayoutFragment.js +44 -0
  140. package/lib/css/layout/LayoutObject.d.ts +46 -0
  141. package/lib/css/layout/LayoutObject.js +182 -0
  142. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  143. package/lib/css/layout/LayoutRegistry.js +87 -0
  144. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  145. package/lib/css/layout/LayoutWorkTask.js +5 -0
  146. package/lib/css/layout/index.d.ts +11 -0
  147. package/lib/css/layout/index.js +148 -0
  148. package/lib/css/layout/types.d.ts +104 -0
  149. package/lib/css/layout/types.js +74 -0
  150. package/lib/css/parser/color.d.ts +1 -1
  151. package/lib/css/parser/color.js +1 -1
  152. package/lib/css/parser/dimension.js +4 -0
  153. package/lib/css/parser/path.d.ts +2 -2
  154. package/lib/css/parser/path.js +9 -2
  155. package/lib/css/parser/points.d.ts +8 -1
  156. package/lib/css/parser/points.js +33 -3
  157. package/lib/css/parser/transform.js +1 -1
  158. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  159. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  160. package/lib/css/properties/CSSPropertyLocalPosition.js +60 -20
  161. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  162. package/lib/css/properties/CSSPropertyPath.js +7 -5
  163. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  164. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  165. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  166. package/lib/display-objects/Circle.d.ts +4 -0
  167. package/lib/display-objects/Circle.js +2 -0
  168. package/lib/display-objects/CustomElement.d.ts +6 -2
  169. package/lib/display-objects/CustomElement.js +13 -4
  170. package/lib/display-objects/DisplayObject.d.ts +1 -7
  171. package/lib/display-objects/DisplayObject.js +6 -27
  172. package/lib/display-objects/Ellipse.d.ts +4 -0
  173. package/lib/display-objects/Ellipse.js +2 -0
  174. package/lib/display-objects/Group.d.ts +4 -0
  175. package/lib/display-objects/Group.js +2 -0
  176. package/lib/display-objects/HTML.d.ts +4 -4
  177. package/lib/display-objects/HTML.js +5 -3
  178. package/lib/display-objects/Image.d.ts +4 -0
  179. package/lib/display-objects/Image.js +2 -0
  180. package/lib/display-objects/Line.js +2 -0
  181. package/lib/display-objects/Path.d.ts +2 -2
  182. package/lib/display-objects/Polygon.js +1 -1
  183. package/lib/display-objects/Polyline.js +1 -1
  184. package/lib/display-objects/Rect.d.ts +6 -2
  185. package/lib/display-objects/Rect.js +2 -0
  186. package/lib/display-objects/Text.d.ts +4 -0
  187. package/lib/display-objects/Text.js +2 -0
  188. package/lib/dom/Element.js +1 -0
  189. package/lib/global-module.js +89 -1
  190. package/lib/index.d.ts +3 -0
  191. package/lib/index.js +7 -2
  192. package/lib/services/EventService.js +10 -2
  193. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  194. package/lib/services/OffscreenCanvasCreator.js +1 -1
  195. package/lib/services/RenderingService.d.ts +1 -1
  196. package/lib/services/RenderingService.js +1 -1
  197. package/lib/services/SceneGraphService.d.ts +2 -0
  198. package/lib/services/SceneGraphService.js +12 -0
  199. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  200. package/lib/services/aabb/CircleUpdater.js +2 -6
  201. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  202. package/lib/services/aabb/EllipseUpdater.js +2 -6
  203. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  204. package/lib/services/aabb/LineUpdater.js +1 -3
  205. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  206. package/lib/services/aabb/PathUpdater.js +1 -5
  207. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  208. package/lib/services/aabb/PolylineUpdater.js +1 -3
  209. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  210. package/lib/services/aabb/RectUpdater.js +1 -5
  211. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  212. package/lib/services/aabb/TextUpdater.js +0 -4
  213. package/lib/services/aabb/interfaces.d.ts +0 -3
  214. package/lib/types.d.ts +7 -23
  215. package/lib/types.js +1 -0
  216. package/lib/utils/deferred.d.ts +43 -0
  217. package/lib/utils/deferred.js +131 -0
  218. package/lib/utils/dom.d.ts +2 -0
  219. package/lib/utils/dom.js +17 -0
  220. package/lib/utils/index.d.ts +2 -0
  221. package/lib/utils/index.js +26 -0
  222. package/lib/utils/interpolation.js +2 -8
  223. package/lib/utils/math.js +4 -3
  224. package/lib/utils/path.d.ts +2 -2
  225. package/lib/utils/path.js +55 -24
  226. package/package.json +3 -3
  227. package/es/css/LayoutRegistry.d.ts +0 -11
  228. package/es/css/LayoutRegistry.js +0 -22
  229. package/lib/css/LayoutRegistry.d.ts +0 -11
  230. package/lib/css/LayoutRegistry.js +0 -30
@@ -1,7 +1,8 @@
1
- import { __decorate, __extends } from "tslib";
1
+ import { __decorate, __extends, __read } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
- import { mergeDimensions, parseLengthOrPercentage } from '../parser';
4
3
  import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
4
+ import { isNil } from '../../utils';
5
+ import { Shape } from '../../types';
5
6
  /**
6
7
  * local position
7
8
  */
@@ -12,19 +13,7 @@ function (_super) {
12
13
  __extends(CSSPropertyLocalPosition, _super);
13
14
 
14
15
  function CSSPropertyLocalPosition() {
15
- var _this = _super !== null && _super.apply(this, arguments) || this;
16
- /**
17
- * <length> & <percentage>
18
- */
19
-
20
-
21
- _this.parser = parseLengthOrPercentage;
22
- /**
23
- * mix between CSS.px(x)
24
- */
25
-
26
- _this.mixer = mergeDimensions;
27
- return _this;
16
+ return _super !== null && _super.apply(this, arguments) || this;
28
17
  }
29
18
  /**
30
19
  * update local position
@@ -32,11 +21,61 @@ function (_super) {
32
21
 
33
22
 
34
23
  CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
35
- var _a = object.parsedStyle,
36
- x = _a.x,
37
- y = _a.y,
38
- z = _a.z;
39
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
24
+ var x;
25
+ var y;
26
+ var z;
27
+
28
+ switch (object.nodeName) {
29
+ case Shape.CIRCLE:
30
+ case Shape.ELLIPSE:
31
+ var _a = object.parsedStyle,
32
+ cx = _a.cx,
33
+ cy = _a.cy;
34
+
35
+ if (!isNil(cx)) {
36
+ x = cx.value;
37
+ }
38
+
39
+ if (!isNil(cy)) {
40
+ y = cy.value;
41
+ }
42
+
43
+ break;
44
+
45
+ case Shape.LINE:
46
+ var _b = object.parsedStyle,
47
+ x1 = _b.x1,
48
+ x2 = _b.x2,
49
+ y1 = _b.y1,
50
+ y2 = _b.y2;
51
+ var minX = Math.min(x1.value, x2.value);
52
+ var minY = Math.min(y1.value, y2.value);
53
+ x = minX;
54
+ y = minY;
55
+ z = 0;
56
+ break;
57
+
58
+ default:
59
+ if (!isNil(object.parsedStyle.x)) {
60
+ x = object.parsedStyle.x.value;
61
+ }
62
+
63
+ if (!isNil(object.parsedStyle.y)) {
64
+ y = object.parsedStyle.y.value;
65
+ }
66
+
67
+ break;
68
+ }
69
+
70
+ object.parsedStyle.defX = x || 0;
71
+ object.parsedStyle.defY = y || 0;
72
+
73
+ var _c = __read(object.getLocalPosition(), 3),
74
+ ox = _c[0],
75
+ oy = _c[1],
76
+ oz = _c[2];
77
+
78
+ object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
40
79
  };
41
80
 
42
81
  CSSPropertyLocalPosition = __decorate([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("../../types").PathCommand[];
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("../../types").PathCommand[];
16
+ curve: import("../..").PathCommand[];
17
17
  totalLength: number;
18
18
  curveSegments: number[][];
19
19
  zCommandIndexes: number[];
@@ -16,7 +16,8 @@ function () {
16
16
  }
17
17
 
18
18
  CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
19
- if (parsed instanceof CSSKeywordValue) {
19
+ // unset
20
+ if (parsed instanceof CSSKeywordValue && parsed.value === 'unset') {
20
21
  return {
21
22
  absolutePath: [],
22
23
  hasArc: false,
@@ -40,10 +41,11 @@ function () {
40
41
 
41
42
  CSSPropertyPath.prototype.postProcessor = function (object) {
42
43
  var _a = object.parsedStyle,
43
- x = _a.x,
44
- y = _a.y,
45
- z = _a.z;
46
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
44
+ _b = _a.defX,
45
+ defX = _b === void 0 ? 0 : _b,
46
+ _c = _a.defY,
47
+ defY = _c === void 0 ? 0 : _c;
48
+ object.setLocalPosition(defX, defY);
47
49
  };
48
50
 
49
51
  CSSPropertyPath = __decorate([singleton()], CSSPropertyPath);
@@ -15,10 +15,9 @@ function () {
15
15
 
16
16
  CSSPropertyPoints.prototype.postProcessor = function (object) {
17
17
  var _a = object.parsedStyle,
18
- x = _a.x,
19
- y = _a.y,
20
- z = _a.z;
21
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
18
+ defX = _a.defX,
19
+ defY = _a.defY;
20
+ object.setLocalPosition(defX, defY);
22
21
  };
23
22
 
24
23
  CSSPropertyPoints = __decorate([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
- calculator(name: string, oldValue: any[], newValue: any[], object: DisplayObject): any[];
37
+ postProcessor(object: DisplayObject): void;
38
38
  }
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
- import { CSSKeywordValue, Opx, Odeg } from '../cssom';
3
+ import { Opx, Odeg } from '../cssom';
4
4
  import { parseTransform, mergeTransforms } from '../parser';
5
5
  /**
6
6
  * @see /zh/docs/api/animation#支持变换的属性
@@ -41,112 +41,84 @@ function () {
41
41
  this.mixer = mergeTransforms;
42
42
  }
43
43
 
44
- CSSPropertyTransform.prototype.calculator = function (name, oldValue, newValue, object) {
45
- if (newValue instanceof CSSKeywordValue) {
46
- newValue = [];
47
- } // const uniqTypes = uniq([
48
- // ...(oldValue || []).map(({ t }) => t),
49
- // ...(newValue || []).map(({ t }) => t),
50
- // ]);
44
+ CSSPropertyTransform.prototype.postProcessor = function (object) {
45
+ var _a = object.parsedStyle,
46
+ transform = _a.transform,
47
+ defX = _a.defX,
48
+ defY = _a.defY;
51
49
 
50
+ if (transform && transform.length) {
51
+ // reset transform
52
+ object.resetLocalTransform();
53
+ object.setLocalPosition(defX, defY);
54
+ transform.forEach(function (_a) {
55
+ var t = _a.t,
56
+ d = _a.d;
52
57
 
53
- newValue.forEach(function (transform) {
54
- var t = transform.t;
55
- var value = (newValue || []).find(function (o) {
56
- return o.t === t;
58
+ if (t === 'scale') {
59
+ // scale(1) scale(1, 1)
60
+ var newScale = d.map(function (s) {
61
+ return s.value;
62
+ }) || [1, 1];
63
+ object.scaleLocal(newScale[0], newScale[1], 1);
64
+ } else if (t === 'scalex') {
65
+ var newScale = d.map(function (s) {
66
+ return s.value;
67
+ }) || [1];
68
+ object.scaleLocal(newScale[0], 1, 1);
69
+ } else if (t === 'scaley') {
70
+ var newScale = d.map(function (s) {
71
+ return s.value;
72
+ }) || [1];
73
+ object.scaleLocal(1, newScale[0], 1);
74
+ } else if (t === 'scalez') {
75
+ var newScale = d.map(function (s) {
76
+ return s.value;
77
+ }) || [1];
78
+ object.scaleLocal(1, 1, newScale[0]);
79
+ } else if (t === 'scale3d') {
80
+ var newScale = d.map(function (s) {
81
+ return s.value;
82
+ }) || [1, 1, 1];
83
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
84
+ } else if (t === 'translate') {
85
+ var newTranslation = d || [Opx, Opx];
86
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
87
+ } else if (t === 'translatex') {
88
+ var newTranslation = d || [Opx];
89
+ object.translateLocal(newTranslation[0].value, 0, 0);
90
+ } else if (t === 'translatey') {
91
+ var newTranslation = d || [Opx];
92
+ object.translateLocal(0, newTranslation[0].value, 0);
93
+ } else if (t === 'translatez') {
94
+ var newTranslation = d || [Opx];
95
+ object.translateLocal(0, 0, newTranslation[0].value);
96
+ } else if (t === 'translate3d') {
97
+ var newTranslation = d || [Opx, Opx, Opx];
98
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
99
+ } else if (t === 'rotate') {
100
+ var newAngles = d || [Odeg];
101
+ object.rotateLocal(0, 0, newAngles[0].value);
102
+ } else if (t === 'rotatex') {
103
+ var newAngles = d || [Odeg];
104
+ object.rotateLocal(newAngles[0].value, 0, 0);
105
+ } else if (t === 'rotatey') {
106
+ var newAngles = d || [Odeg];
107
+ object.rotateLocal(0, newAngles[0].value, 0);
108
+ } else if (t === 'rotatez') {
109
+ var newAngles = d || [Odeg];
110
+ object.rotateLocal(0, 0, newAngles[0].value);
111
+ } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
112
+ // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
113
+ // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
114
+ // object.rotateLocal(
115
+ // newAngles[0].value - oldAngles[0].value,
116
+ // newAngles[1].value - oldAngles[1].value,
117
+ // newAngles[2].value - oldAngles[2].value,
118
+ // );
119
+ }
57
120
  });
58
- var old = (oldValue || []).find(function (o) {
59
- return o.t === t;
60
- });
61
-
62
- if (t === 'scale') {
63
- // scale(1) scale(1, 1)
64
- var newScale = value && value.d && value.d.map(function (s) {
65
- return s.value;
66
- }) || [1, 1];
67
- var oldScale = old && old.d && old.d.map(function (s) {
68
- return s.value;
69
- }) || [1, 1];
70
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], 1);
71
- } else if (t === 'scalex') {
72
- var newScale = value && value.d && value.d.map(function (s) {
73
- return s.value;
74
- }) || [1];
75
- var oldScale = old && old.d && old.d.map(function (s) {
76
- return s.value;
77
- }) || [1];
78
- object.scaleLocal(newScale[0] / oldScale[0], 1, 1);
79
- } else if (t === 'scaley') {
80
- var newScale = value && value.d && value.d.map(function (s) {
81
- return s.value;
82
- }) || [1];
83
- var oldScale = old && old.d && old.d.map(function (s) {
84
- return s.value;
85
- }) || [1];
86
- object.scaleLocal(1, newScale[0] / oldScale[0], 1);
87
- } else if (t === 'scalez') {
88
- var newScale = value && value.d && value.d.map(function (s) {
89
- return s.value;
90
- }) || [1];
91
- var oldScale = old && old.d && old.d.map(function (s) {
92
- return s.value;
93
- }) || [1];
94
- object.scaleLocal(1, 1, newScale[0] / oldScale[0]);
95
- } else if (t === 'scale3d') {
96
- var newScale = value && value.d && value.d.map(function (s) {
97
- return s.value;
98
- }) || [1, 1, 1];
99
- var oldScale = old && old.d && old.d.map(function (s) {
100
- return s.value;
101
- }) || [1, 1, 1];
102
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], newScale[2] / oldScale[2]);
103
- } else if (t === 'translate') {
104
- var newTranslation = value && value.d || [Opx, Opx];
105
- var oldTranslation = old && old.d || [Opx, Opx];
106
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, 0);
107
- } else if (t === 'translatex') {
108
- var newTranslation = value && value.d || [Opx];
109
- var oldTranslation = old && old.d || [Opx];
110
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, 0, 0);
111
- } else if (t === 'translatey') {
112
- var newTranslation = value && value.d || [Opx];
113
- var oldTranslation = old && old.d || [Opx];
114
- object.translateLocal(0, newTranslation[0].value - oldTranslation[0].value, 0);
115
- } else if (t === 'translatez') {
116
- var newTranslation = value && value.d || [Opx];
117
- var oldTranslation = old && old.d || [Opx];
118
- object.translateLocal(0, 0, newTranslation[0].value - oldTranslation[0].value);
119
- } else if (t === 'translate3d') {
120
- var newTranslation = value && value.d || [Opx, Opx, Opx];
121
- var oldTranslation = old && old.d || [Opx, Opx, Opx];
122
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, newTranslation[2].value - oldTranslation[2].value);
123
- } else if (t === 'rotate') {
124
- var newAngles = value && value.d || [Odeg];
125
- var oldAngles = old && old.d || [Odeg];
126
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
127
- } else if (t === 'rotatex') {
128
- var newAngles = value && value.d || [Odeg];
129
- var oldAngles = old && old.d || [Odeg];
130
- object.rotateLocal(newAngles[0].value - oldAngles[0].value, 0, 0);
131
- } else if (t === 'rotatey') {
132
- var newAngles = value && value.d || [Odeg];
133
- var oldAngles = old && old.d || [Odeg];
134
- object.rotateLocal(0, newAngles[0].value - oldAngles[0].value, 0);
135
- } else if (t === 'rotatez') {
136
- var newAngles = value && value.d || [Odeg];
137
- var oldAngles = old && old.d || [Odeg];
138
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
139
- } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
140
- // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
141
- // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
142
- // object.rotateLocal(
143
- // newAngles[0].value - oldAngles[0].value,
144
- // newAngles[1].value - oldAngles[1].value,
145
- // newAngles[2].value - oldAngles[2].value,
146
- // );
147
- }
148
- });
149
- return newValue;
121
+ }
150
122
  };
151
123
 
152
124
  CSSPropertyTransform = __decorate([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> {
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.CIRCLE,
20
20
  style: __assign({
21
+ cx: '',
22
+ cy: '',
21
23
  r: '',
22
24
  anchor: [0.5, 0.5],
23
25
  transformOrigin: 'center',
@@ -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 BaseStyleProps> extends DisplayObject<CustomElementStyleProps> {
9
- constructor(config?: DisplayObjectConfig<CustomElementStyleProps>);
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
  */
@@ -1,4 +1,4 @@
1
- import { __extends } from "tslib";
1
+ import { __assign, __extends, __rest } from "tslib";
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import { ElementEvent } from '../dom/interfaces';
4
4
  /**
@@ -12,12 +12,22 @@ function (_super) {
12
12
  __extends(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
13
13
 
14
14
 
15
- function CustomElement(config) {
16
- if (config === void 0) {
17
- config = {};
15
+ function CustomElement(_a) {
16
+ if (_a === void 0) {
17
+ _a = {};
18
18
  }
19
19
 
20
- var _this = _super.call(this, config) || this;
20
+ var _this = this;
21
+
22
+ var style = _a.style,
23
+ rest = __rest(_a, ["style"]);
24
+
25
+ _this = _super.call(this, __assign({
26
+ style: __assign({
27
+ x: '',
28
+ y: ''
29
+ }, style)
30
+ }, rest)) || this;
21
31
 
22
32
  _this.handleMounted = function (e) {
23
33
  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
@@ -11,17 +11,14 @@ import { dirtifyToRoot } from '../services';
11
11
  import { MutationEvent } from '../dom/MutationEvent';
12
12
  import { Rectangle } from '../shapes';
13
13
  import { StyleValueRegistry } from '../css/interfaces';
14
- import { CSSUnitValue } from '../css';
15
14
  var DEFAULT_STYLE_PROPS = {
16
- x: '',
17
- y: '',
18
- z: '',
19
15
  anchor: [0, 0],
20
16
  opacity: '',
21
17
  fillOpacity: '',
22
18
  strokeOpacity: '',
23
19
  fill: '',
24
20
  stroke: '',
21
+ transform: '',
25
22
  transformOrigin: '',
26
23
  visibility: '',
27
24
  pointerEvents: '',
@@ -284,7 +281,6 @@ function (_super) {
284
281
  }
285
282
 
286
283
  this.sceneGraphService.setPosition(this, createVec3(position, y, z));
287
- this.syncLocalPosition();
288
284
  return this;
289
285
  };
290
286
  /**
@@ -302,7 +298,6 @@ function (_super) {
302
298
  }
303
299
 
304
300
  this.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
305
- this.syncLocalPosition();
306
301
  return this;
307
302
  };
308
303
  /**
@@ -320,7 +315,6 @@ function (_super) {
320
315
  }
321
316
 
322
317
  this.sceneGraphService.translate(this, createVec3(position, y, z));
323
- this.syncLocalPosition();
324
318
  return this;
325
319
  };
326
320
  /**
@@ -338,7 +332,6 @@ function (_super) {
338
332
  }
339
333
 
340
334
  this.sceneGraphService.translateLocal(this, createVec3(position, y, z));
341
- this.syncLocalPosition();
342
335
  return this;
343
336
  };
344
337
 
@@ -497,26 +490,13 @@ function (_super) {
497
490
  return this.sceneGraphService.getWorldTransform(this);
498
491
  };
499
492
 
500
- DisplayObject.prototype.resetLocalTransform = function () {
501
- this.sceneGraphService.resetLocalTransform(this);
493
+ DisplayObject.prototype.setLocalTransform = function (transform) {
494
+ this.sceneGraphService.setLocalTransform(this, transform);
495
+ return this;
502
496
  };
503
- /**
504
- * sync style.x/y when local position changed
505
- *
506
- * Mixins may not declare private/protected properties
507
- * however, you can use ES2020 private fields
508
- */
509
-
510
-
511
- DisplayObject.prototype.syncLocalPosition = function () {
512
- var localPosition = this.getLocalPosition();
513
- this.attributes.x = localPosition[0];
514
- this.attributes.y = localPosition[1];
515
- this.attributes.z = localPosition[2]; // should not affect computed style
516
497
 
517
- this.parsedStyle.x = new CSSUnitValue(this.attributes.x, 'px');
518
- this.parsedStyle.y = new CSSUnitValue(this.attributes.y, 'px');
519
- this.parsedStyle.z = new CSSUnitValue(this.attributes.z, 'px');
498
+ DisplayObject.prototype.resetLocalTransform = function () {
499
+ this.sceneGraphService.resetLocalTransform(this);
520
500
  }; // #endregion transformable
521
501
  // #region animatable
522
502
 
@@ -3,10 +3,14 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface EllipseStyleProps extends BaseStyleProps {
6
+ cx?: number | string;
7
+ cy?: number | string;
6
8
  rx: number | string;
7
9
  ry: number | string;
8
10
  }
9
11
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
12
+ cx: CSSUnitValue;
13
+ cy: CSSUnitValue;
10
14
  rx: CSSUnitValue;
11
15
  ry: CSSUnitValue;
12
16
  }
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.ELLIPSE,
20
20
  style: __assign({
21
+ cx: '',
22
+ cy: '',
21
23
  rx: '',
22
24
  ry: '',
23
25
  anchor: [0.5, 0.5],
@@ -3,10 +3,14 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface GroupStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width?: number | string;
7
9
  height?: number | string;
8
10
  }
9
11
  export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
12
+ x: CSSUnitValue;
13
+ y: CSSUnitValue;
10
14
  width?: CSSUnitValue;
11
15
  height?: CSSUnitValue;
12
16
  }
@@ -28,6 +28,8 @@ function (_super) {
28
28
  return _super.call(this, __assign({
29
29
  type: Shape.GROUP,
30
30
  style: __assign({
31
+ x: '',
32
+ y: '',
31
33
  width: '',
32
34
  height: ''
33
35
  }, style)
@@ -4,19 +4,19 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
5
  import type { CSSUnitValue } from '../css';
6
6
  export interface HTMLStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  innerHTML: string | HTMLElement;
8
10
  width: number;
9
11
  height: number;
10
- className?: string | string[];
11
- style?: string;
12
12
  }
13
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
14
16
  $el: HTMLElement;
15
17
  innerHTML: string | HTMLElement;
16
18
  width: CSSUnitValue;
17
19
  height: CSSUnitValue;
18
- className?: string | string[];
19
- style?: string;
20
20
  }
21
21
  /**
22
22
  * HTML container
@@ -26,9 +26,11 @@ function (_super) {
26
26
  _this = _super.call(this, __assign({
27
27
  type: Shape.HTML,
28
28
  style: __assign({
29
- innerHTML: '',
30
- className: '',
31
- style: ''
29
+ x: '',
30
+ y: '',
31
+ width: '',
32
+ height: '',
33
+ innerHTML: ''
32
34
  }, style)
33
35
  }, rest)) || this;
34
36
  _this.cullable.enable = false;
@@ -3,12 +3,16 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface ImageStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  img?: string | HTMLImageElement;
7
9
  src?: string | HTMLImageElement;
8
10
  width?: number | string;
9
11
  height?: number | string;
10
12
  }
11
13
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
12
16
  img?: string | HTMLImageElement;
13
17
  src?: string | HTMLImageElement;
14
18
  width?: CSSUnitValue;
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.IMAGE,
20
20
  style: __assign({
21
+ x: '',
22
+ y: '',
21
23
  img: '',
22
24
  width: '',
23
25
  height: '',
@@ -37,6 +37,7 @@ function (_super) {
37
37
  }
38
38
 
39
39
  Line.prototype.getPoint = function (ratio) {
40
+ // TODO: account for z1/z2 in 3D line
40
41
  var _a = this.parsedStyle,
41
42
  x1 = _a.x1,
42
43
  y1 = _a.y1,
@@ -47,6 +48,7 @@ function (_super) {
47
48
  };
48
49
 
49
50
  Line.prototype.getTotalLength = function () {
51
+ // TODO: account for z1/z2 in 3D line
50
52
  var _a = this.parsedStyle,
51
53
  x1 = _a.x1,
52
54
  y1 = _a.y1,