@antv/g 5.0.24 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +2 -0
  3. package/es/css/CSSProperty.d.ts +2 -1
  4. package/es/css/StyleValueRegistry.d.ts +2 -1
  5. package/es/css/StyleValueRegistry.js +68 -72
  6. package/es/css/parser/color.d.ts +1 -1
  7. package/es/css/parser/color.js +2 -2
  8. package/es/css/parser/dimension.js +5 -1
  9. package/es/css/parser/path.d.ts +2 -2
  10. package/es/css/parser/path.js +9 -2
  11. package/es/css/parser/points.d.ts +8 -1
  12. package/es/css/parser/points.js +33 -3
  13. package/es/css/parser/transform.js +1 -1
  14. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  15. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  16. package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
  17. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  18. package/es/css/properties/CSSPropertyPath.js +7 -5
  19. package/es/css/properties/CSSPropertyPoints.js +3 -4
  20. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  21. package/es/css/properties/CSSPropertyTransform.js +76 -104
  22. package/es/display-objects/Circle.d.ts +4 -0
  23. package/es/display-objects/Circle.js +2 -0
  24. package/es/display-objects/DisplayObject.d.ts +1 -7
  25. package/es/display-objects/DisplayObject.js +6 -26
  26. package/es/display-objects/Ellipse.d.ts +4 -0
  27. package/es/display-objects/Ellipse.js +2 -0
  28. package/es/display-objects/Group.d.ts +4 -0
  29. package/es/display-objects/Group.js +2 -0
  30. package/es/display-objects/HTML.d.ts +4 -4
  31. package/es/display-objects/HTML.js +5 -3
  32. package/es/display-objects/Image.d.ts +4 -0
  33. package/es/display-objects/Image.js +2 -0
  34. package/es/display-objects/Line.js +2 -0
  35. package/es/display-objects/Path.d.ts +2 -2
  36. package/es/display-objects/Polygon.js +1 -1
  37. package/es/display-objects/Polyline.js +1 -1
  38. package/es/display-objects/Rect.d.ts +6 -2
  39. package/es/display-objects/Rect.js +2 -0
  40. package/es/display-objects/Text.d.ts +4 -0
  41. package/es/display-objects/Text.js +2 -0
  42. package/es/dom/Element.js +1 -0
  43. package/es/services/EventService.js +10 -2
  44. package/es/services/SceneGraphService.d.ts +2 -0
  45. package/es/services/SceneGraphService.js +9 -0
  46. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  47. package/es/services/aabb/CircleUpdater.js +2 -6
  48. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  49. package/es/services/aabb/EllipseUpdater.js +2 -6
  50. package/es/services/aabb/LineUpdater.d.ts +0 -2
  51. package/es/services/aabb/LineUpdater.js +1 -3
  52. package/es/services/aabb/PathUpdater.d.ts +0 -2
  53. package/es/services/aabb/PathUpdater.js +1 -5
  54. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  55. package/es/services/aabb/PolylineUpdater.js +1 -3
  56. package/es/services/aabb/RectUpdater.d.ts +0 -2
  57. package/es/services/aabb/RectUpdater.js +1 -5
  58. package/es/services/aabb/TextUpdater.d.ts +7 -0
  59. package/es/services/aabb/TextUpdater.js +0 -4
  60. package/es/services/aabb/interfaces.d.ts +0 -3
  61. package/es/types.d.ts +6 -19
  62. package/es/types.js +1 -0
  63. package/es/utils/interpolation.js +2 -8
  64. package/es/utils/math.js +4 -3
  65. package/es/utils/path.d.ts +2 -2
  66. package/es/utils/path.js +61 -24
  67. package/lib/Canvas.js +2 -0
  68. package/lib/css/CSSProperty.d.ts +2 -1
  69. package/lib/css/StyleValueRegistry.d.ts +2 -1
  70. package/lib/css/StyleValueRegistry.js +67 -71
  71. package/lib/css/parser/color.d.ts +1 -1
  72. package/lib/css/parser/color.js +1 -1
  73. package/lib/css/parser/dimension.js +4 -0
  74. package/lib/css/parser/path.d.ts +2 -2
  75. package/lib/css/parser/path.js +9 -2
  76. package/lib/css/parser/points.d.ts +8 -1
  77. package/lib/css/parser/points.js +33 -3
  78. package/lib/css/parser/transform.js +1 -1
  79. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  80. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  81. package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
  82. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  83. package/lib/css/properties/CSSPropertyPath.js +7 -5
  84. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  85. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  86. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  87. package/lib/display-objects/Circle.d.ts +4 -0
  88. package/lib/display-objects/Circle.js +2 -0
  89. package/lib/display-objects/DisplayObject.d.ts +1 -7
  90. package/lib/display-objects/DisplayObject.js +6 -27
  91. package/lib/display-objects/Ellipse.d.ts +4 -0
  92. package/lib/display-objects/Ellipse.js +2 -0
  93. package/lib/display-objects/Group.d.ts +4 -0
  94. package/lib/display-objects/Group.js +2 -0
  95. package/lib/display-objects/HTML.d.ts +4 -4
  96. package/lib/display-objects/HTML.js +5 -3
  97. package/lib/display-objects/Image.d.ts +4 -0
  98. package/lib/display-objects/Image.js +2 -0
  99. package/lib/display-objects/Line.js +2 -0
  100. package/lib/display-objects/Path.d.ts +2 -2
  101. package/lib/display-objects/Polygon.js +1 -1
  102. package/lib/display-objects/Polyline.js +1 -1
  103. package/lib/display-objects/Rect.d.ts +6 -2
  104. package/lib/display-objects/Rect.js +2 -0
  105. package/lib/display-objects/Text.d.ts +4 -0
  106. package/lib/display-objects/Text.js +2 -0
  107. package/lib/dom/Element.js +1 -0
  108. package/lib/services/EventService.js +10 -2
  109. package/lib/services/SceneGraphService.d.ts +2 -0
  110. package/lib/services/SceneGraphService.js +12 -0
  111. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  112. package/lib/services/aabb/CircleUpdater.js +2 -6
  113. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  114. package/lib/services/aabb/EllipseUpdater.js +2 -6
  115. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  116. package/lib/services/aabb/LineUpdater.js +1 -3
  117. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  118. package/lib/services/aabb/PathUpdater.js +1 -5
  119. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  120. package/lib/services/aabb/PolylineUpdater.js +1 -3
  121. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  122. package/lib/services/aabb/RectUpdater.js +1 -5
  123. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  124. package/lib/services/aabb/TextUpdater.js +0 -4
  125. package/lib/services/aabb/interfaces.d.ts +0 -3
  126. package/lib/types.d.ts +6 -19
  127. package/lib/types.js +1 -0
  128. package/lib/utils/interpolation.js +2 -8
  129. package/lib/utils/math.js +4 -3
  130. package/lib/utils/path.d.ts +2 -2
  131. package/lib/utils/path.js +55 -24
  132. package/package.json +3 -3
@@ -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',
@@ -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,
@@ -4,8 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rectangle } from '../shapes/Rectangle';
6
6
  export interface PathStyleProps extends BaseStyleProps {
7
- path?: string | PathCommand[];
8
- d?: string | PathCommand[];
7
+ path?: string | PathCommand[] | DisplayObject;
8
+ d?: string | PathCommand[] | DisplayObject;
9
9
  }
10
10
  export interface PathSegment {
11
11
  command: PathCommand[0];
@@ -18,7 +18,7 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.POLYGON,
20
20
  style: __assign({
21
- points: [],
21
+ points: '',
22
22
  miterLimit: 4,
23
23
  lineWidth: 1
24
24
  }, style)
@@ -20,7 +20,7 @@ function (_super) {
20
20
  return _super.call(this, __assign({
21
21
  type: Shape.POLYLINE,
22
22
  style: __assign({
23
- points: [],
23
+ points: '',
24
24
  lineWidth: 1,
25
25
  miterLimit: 4
26
26
  }, style)
@@ -3,13 +3,17 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface RectStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width: number | string;
7
9
  height: number | string;
8
10
  radius?: number | string;
9
11
  }
10
12
  export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
11
- width?: CSSUnitValue;
12
- height?: CSSUnitValue;
13
+ x: CSSUnitValue;
14
+ y: CSSUnitValue;
15
+ width: CSSUnitValue;
16
+ height: CSSUnitValue;
13
17
  radius?: CSSUnitValue;
14
18
  }
15
19
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.RECT,
20
20
  style: __assign({
21
+ x: '',
22
+ y: '',
21
23
  width: '',
22
24
  height: '',
23
25
  radius: '',
@@ -4,6 +4,8 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import type { CSSUnitValue, CSSGlobalKeywords, CSSKeywordValue } from '../css';
6
6
  export interface TextStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  text: string;
8
10
  /** 设置文本内容的当前对齐方式 */
9
11
  textAlign?: CSSGlobalKeywords | 'start' | 'center' | 'end' | 'left' | 'right';
@@ -31,6 +33,8 @@ export interface TextStyleProps extends BaseStyleProps {
31
33
  dy?: number | string;
32
34
  }
33
35
  export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
36
+ x: CSSUnitValue;
37
+ y: CSSUnitValue;
34
38
  text: string;
35
39
  /** 设置文本内容的当前对齐方式 */
36
40
  textAlign?: CSSKeywordValue;
@@ -23,6 +23,8 @@ function (_super) {
23
23
  _this = _super.call(this, __assign({
24
24
  type: Shape.TEXT,
25
25
  style: __assign({
26
+ x: '',
27
+ y: '',
26
28
  text: '',
27
29
  fontSize: '',
28
30
  fontFamily: '',
package/es/dom/Element.js CHANGED
@@ -541,6 +541,7 @@ function (_super) {
541
541
 
542
542
 
543
543
  Element.prototype.removeAttribute = function (attributeName) {
544
+ this.setAttribute(attributeName, null);
544
545
  delete this.attributes[attributeName];
545
546
  };
546
547
  /**
@@ -355,7 +355,11 @@ function (_super) {
355
355
  while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
356
356
  leaveEvent.currentTarget = leaveEvent.target;
357
357
  this.notifyTarget(leaveEvent);
358
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
358
+
359
+ if (isMouse) {
360
+ // console.error(leaveEvent.target);
361
+ this.notifyTarget(leaveEvent, 'mouseleave');
362
+ }
359
363
 
360
364
  if (Node.isNode(leaveEvent.target)) {
361
365
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -460,7 +464,11 @@ function (_super) {
460
464
  while (leaveEvent.target && leaveEvent.target !== (Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
461
465
  leaveEvent.currentTarget = leaveEvent.target;
462
466
  this.notifyTarget(leaveEvent);
463
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
467
+
468
+ if (isMouse) {
469
+ // console.error(leaveEvent.target, 'out');
470
+ this.notifyTarget(leaveEvent, 'mouseleave');
471
+ }
464
472
 
465
473
  if (Node.isNode(leaveEvent.target)) {
466
474
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -35,6 +35,7 @@ export interface SceneGraphService {
35
35
  getLocalRotation: (element: INode) => quat;
36
36
  getWorldTransform: (element: INode, transform?: Transform) => mat4;
37
37
  getLocalTransform: (element: INode, transform?: Transform) => mat4;
38
+ setLocalTransform: (element: INode, transform: mat4) => void;
38
39
  resetLocalTransform: (element: INode) => void;
39
40
  getBounds: (element: INode, render?: boolean) => AABB;
40
41
  getLocalBounds: (element: INode, render?: boolean) => AABB;
@@ -129,6 +130,7 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
129
130
  getLocalRotation(element: INode): import("gl-matrix").vec4;
130
131
  getLocalScale(element: INode): vec3;
131
132
  getLocalTransform(element: INode): mat4;
133
+ setLocalTransform(element: INode, transform: mat4): void;
132
134
  resetLocalTransform(element: INode): void;
133
135
  private getTransformedGeometryBounds;
134
136
  /**
@@ -554,6 +554,15 @@ function () {
554
554
  return transform.localTransform;
555
555
  };
556
556
 
557
+ DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
558
+ var t = mat4.getTranslation(vec3.create(), transform);
559
+ var r = mat4.getRotation(quat.create(), transform);
560
+ var s = mat4.getScaling(vec3.create(), transform);
561
+ this.setLocalScale(element, s);
562
+ this.setLocalPosition(element, t);
563
+ this.setLocalRotation(element, r);
564
+ };
565
+
557
566
  DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
558
567
  this.setLocalScale(element, [1, 1, 1]);
559
568
  this.setLocalPosition(element, [0, 0, 0]);
@@ -4,7 +4,5 @@ export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleSt
4
4
  update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -9,16 +9,12 @@ function () {
9
9
  function CircleUpdater() {}
10
10
 
11
11
  CircleUpdater.prototype.update = function (parsedStyle, object) {
12
- var r = parsedStyle.r,
13
- x = parsedStyle.x,
14
- y = parsedStyle.y;
12
+ var r = parsedStyle.r;
15
13
  var width = r.value * 2;
16
14
  var height = r.value * 2;
17
15
  return {
18
16
  width: width,
19
- height: height,
20
- x: x.value || 0,
21
- y: y.value || 0
17
+ height: height
22
18
  };
23
19
  };
24
20
 
@@ -4,7 +4,5 @@ export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipse
4
4
  update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }