@antv/g 5.0.12 → 5.0.15

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 (82) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +1 -0
  3. package/es/canvas-module.js +7 -15
  4. package/es/display-objects/Circle.d.ts +3 -1
  5. package/es/display-objects/DisplayObject.js +6 -2
  6. package/es/display-objects/Ellipse.d.ts +5 -2
  7. package/es/display-objects/Group.js +4 -1
  8. package/es/display-objects/HTML.d.ts +5 -0
  9. package/es/display-objects/HTML.js +1 -1
  10. package/es/display-objects/Image.d.ts +7 -4
  11. package/es/display-objects/Image.js +3 -1
  12. package/es/display-objects/Rect.d.ts +7 -4
  13. package/es/display-objects/Rect.js +2 -2
  14. package/es/display-objects/Text.d.ts +0 -2
  15. package/es/display-objects/Text.js +2 -2
  16. package/es/dom/Element.d.ts +4 -4
  17. package/es/dom/Element.js +2 -1
  18. package/es/dom/FederatedPointerEvent.d.ts +6 -0
  19. package/es/dom/FederatedPointerEvent.js +8 -0
  20. package/es/global-module.d.ts +3 -1
  21. package/es/global-module.js +30 -70
  22. package/es/property-handlers/aabb.js +3 -4
  23. package/es/property-handlers/anchor.js +2 -1
  24. package/es/property-handlers/dimension.d.ts +2 -1
  25. package/es/property-handlers/dimension.js +30 -2
  26. package/es/property-handlers/path.d.ts +1 -1
  27. package/es/services/SceneGraphService.d.ts +7 -9
  28. package/es/services/SceneGraphService.js +59 -71
  29. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  30. package/es/services/aabb/CircleUpdater.js +19 -9
  31. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  32. package/es/services/aabb/EllipseUpdater.js +26 -11
  33. package/es/services/aabb/RectUpdater.d.ts +2 -2
  34. package/es/services/aabb/RectUpdater.js +30 -14
  35. package/es/services/aabb/interfaces.d.ts +1 -1
  36. package/es/services/aabb/interfaces.js +1 -1
  37. package/es/shapes/AABB.d.ts +1 -0
  38. package/es/shapes/AABB.js +8 -0
  39. package/es/types.d.ts +0 -3
  40. package/es/utils/path.d.ts +1 -1
  41. package/es/utils/path.js +5 -5
  42. package/lib/Canvas.js +1 -0
  43. package/lib/canvas-module.js +9 -16
  44. package/lib/display-objects/Circle.d.ts +3 -1
  45. package/lib/display-objects/DisplayObject.js +6 -2
  46. package/lib/display-objects/Ellipse.d.ts +5 -2
  47. package/lib/display-objects/Group.js +4 -1
  48. package/lib/display-objects/HTML.d.ts +5 -0
  49. package/lib/display-objects/HTML.js +1 -1
  50. package/lib/display-objects/Image.d.ts +7 -4
  51. package/lib/display-objects/Image.js +3 -1
  52. package/lib/display-objects/Rect.d.ts +7 -4
  53. package/lib/display-objects/Rect.js +2 -2
  54. package/lib/display-objects/Text.d.ts +0 -2
  55. package/lib/display-objects/Text.js +2 -2
  56. package/lib/dom/Element.d.ts +4 -4
  57. package/lib/dom/Element.js +2 -1
  58. package/lib/dom/FederatedPointerEvent.d.ts +6 -0
  59. package/lib/dom/FederatedPointerEvent.js +8 -0
  60. package/lib/global-module.d.ts +3 -1
  61. package/lib/global-module.js +34 -70
  62. package/lib/property-handlers/aabb.js +3 -4
  63. package/lib/property-handlers/anchor.js +3 -1
  64. package/lib/property-handlers/dimension.d.ts +2 -1
  65. package/lib/property-handlers/dimension.js +33 -2
  66. package/lib/property-handlers/path.d.ts +1 -1
  67. package/lib/services/SceneGraphService.d.ts +7 -9
  68. package/lib/services/SceneGraphService.js +59 -71
  69. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  70. package/lib/services/aabb/CircleUpdater.js +19 -9
  71. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  72. package/lib/services/aabb/EllipseUpdater.js +26 -11
  73. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  74. package/lib/services/aabb/RectUpdater.js +30 -14
  75. package/lib/services/aabb/interfaces.d.ts +1 -1
  76. package/lib/services/aabb/interfaces.js +1 -1
  77. package/lib/shapes/AABB.d.ts +1 -0
  78. package/lib/shapes/AABB.js +8 -0
  79. package/lib/types.d.ts +0 -3
  80. package/lib/utils/path.d.ts +1 -1
  81. package/lib/utils/path.js +5 -5
  82. package/package.json +4 -4
@@ -56,72 +56,6 @@ var DefaultSceneGraphService =
56
56
  function () {
57
57
  function DefaultSceneGraphService() {
58
58
  var _this = this;
59
- /**
60
- * compare two display objects by hierarchy-index and z-index
61
- *
62
- * use materialized path
63
- * @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
64
- */
65
-
66
-
67
- this.sort = function (object1, object2) {
68
- if (!object1.parentNode) {
69
- return -1;
70
- }
71
-
72
- if (!object2.parentNode) {
73
- return 1;
74
- }
75
-
76
- var hierarchyDiff = object1.transformable.graphDepth - object2.transformable.graphDepth;
77
- var o1 = object1;
78
- var o2 = object2;
79
-
80
- if (hierarchyDiff < 0) {
81
- o2 = object2.getAncestor(-hierarchyDiff);
82
-
83
- if (o2 === o1) {
84
- return -1;
85
- }
86
- } else if (hierarchyDiff > 0) {
87
- o1 = object1.getAncestor(hierarchyDiff);
88
-
89
- if (o2 === o1) {
90
- return 1;
91
- }
92
- }
93
-
94
- while (o1 && o2 && o1.parentNode !== o2.parentNode) {
95
- o1 = o1.parentNode;
96
- o2 = o2.parentNode;
97
- }
98
-
99
- var parent = o1.parentNode;
100
-
101
- if (parent) {
102
- var parentSortable = parent.sortable;
103
-
104
- if (parentSortable) {
105
- // no need to re-sort, use cached sorted children
106
- if (!parentSortable.sorted) {
107
- parentSortable.sorted = parent.childNodes.slice();
108
- }
109
-
110
- if (parentSortable.dirty) {
111
- parentSortable.sorted = parent.childNodes.slice().sort(sortByZIndex); // parentSortable.sorted.forEach(
112
- // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
113
- // );
114
-
115
- parentSortable.dirty = false;
116
- } // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
117
-
118
-
119
- return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
120
- }
121
- }
122
-
123
- return -1;
124
- };
125
59
  /**
126
60
  * rotate in world space
127
61
  */
@@ -437,6 +371,60 @@ function () {
437
371
  child.parentNode = null;
438
372
  }
439
373
  };
374
+ /**
375
+ * compare two display objects by hierarchy-index and z-index
376
+ *
377
+ * use materialized path
378
+ * @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
379
+ */
380
+ // sort = (object1: INode, object2: INode): number => {
381
+ // if (!object1.parentNode) {
382
+ // return -1;
383
+ // }
384
+ // if (!object2.parentNode) {
385
+ // return 1;
386
+ // }
387
+ // const hierarchyDiff =
388
+ // (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
389
+ // let o1 = object1;
390
+ // let o2 = object2;
391
+ // if (hierarchyDiff < 0) {
392
+ // o2 = object2.getAncestor(-hierarchyDiff)!;
393
+ // if (o2 === o1) {
394
+ // return -1;
395
+ // }
396
+ // } else if (hierarchyDiff > 0) {
397
+ // o1 = object1.getAncestor(hierarchyDiff)!;
398
+ // if (o2 === o1) {
399
+ // return 1;
400
+ // }
401
+ // }
402
+ // while (o1 && o2 && o1.parentNode !== o2.parentNode) {
403
+ // o1 = o1.parentNode!;
404
+ // o2 = o2.parentNode!;
405
+ // }
406
+ // const parent = o1.parentNode;
407
+ // if (parent) {
408
+ // const parentSortable = (parent as Element).sortable;
409
+ // if (parentSortable) {
410
+ // // no need to re-sort, use cached sorted children
411
+ // if (!parentSortable.sorted) {
412
+ // parentSortable.sorted = (parent.childNodes as IElement[]).slice();
413
+ // }
414
+ // if (parentSortable.dirty) {
415
+ // parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
416
+ // // parentSortable.sorted.forEach(
417
+ // // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
418
+ // // );
419
+ // parentSortable.dirty = false;
420
+ // }
421
+ // // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
422
+ // return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
423
+ // }
424
+ // }
425
+ // return -1;
426
+ // };
427
+
440
428
 
441
429
  DefaultSceneGraphService.prototype.getOrigin = function (element) {
442
430
  return element.transformable.origin;
@@ -625,7 +613,7 @@ function () {
625
613
 
626
614
  var bounds = this.getGeometryBounds(element, render);
627
615
 
628
- if (bounds) {
616
+ if (!AABB.isEmpty(bounds)) {
629
617
  var aabb = new AABB();
630
618
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
631
619
  return aabb;
@@ -645,7 +633,7 @@ function () {
645
633
 
646
634
  var geometry = element.geometry;
647
635
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
648
- return bounds && new AABB(bounds.center, bounds.halfExtents) || null;
636
+ return bounds && new AABB(bounds.center, bounds.halfExtents) || new AABB();
649
637
  };
650
638
  /**
651
639
  * account for children in world space
@@ -719,7 +707,7 @@ function () {
719
707
  renderable.boundsDirty = false;
720
708
  }
721
709
 
722
- return aabb || null;
710
+ return aabb || new AABB();
723
711
  };
724
712
  /**
725
713
  * account for children in local space
@@ -736,7 +724,7 @@ function () {
736
724
 
737
725
  var bounds = this.getBounds(element);
738
726
 
739
- if (bounds) {
727
+ if (!AABB.isEmpty(bounds)) {
740
728
  var localBounds = new AABB();
741
729
  localBounds.setFromTransformedAABB(bounds, parentInvert);
742
730
  return localBounds;
@@ -752,7 +740,7 @@ function () {
752
740
  var aabb;
753
741
  var bounds = this.getGeometryBounds(element);
754
742
 
755
- if (bounds) {
743
+ if (!AABB.isEmpty(bounds)) {
756
744
  aabb = new AABB(); // apply transformation to aabb
757
745
 
758
746
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedCircleStyleProps } from '../../display-objects/Circle';
2
+ import type { Circle, ParsedCircleStyleProps } from '../../display-objects/Circle';
3
3
  export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleStyleProps> {
4
- update(parsedStyle: ParsedCircleStyleProps): {
4
+ update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -8,16 +8,26 @@ var CircleUpdater =
8
8
  function () {
9
9
  function CircleUpdater() {}
10
10
 
11
- CircleUpdater.prototype.update = function (parsedStyle) {
12
- var _a = parsedStyle.r,
13
- r = _a === void 0 ? 0 : _a,
14
- _b = parsedStyle.x,
15
- x = _b === void 0 ? 0 : _b,
16
- _c = parsedStyle.y,
17
- y = _c === void 0 ? 0 : _c;
11
+ CircleUpdater.prototype.update = function (parsedStyle, object) {
12
+ var r = parsedStyle.r,
13
+ _a = parsedStyle.x,
14
+ x = _a === void 0 ? 0 : _a,
15
+ _b = parsedStyle.y,
16
+ y = _b === void 0 ? 0 : _b;
17
+ var unit = r.unit,
18
+ value = r.value;
19
+ var width = 0;
20
+ var height = 0;
21
+
22
+ if (unit === '' || unit === 'px') {
23
+ width = value * 2;
24
+ height = value * 2;
25
+ }
26
+
27
+ object.parsedStyle.rInPixels = width / 2;
18
28
  return {
19
- width: r * 2,
20
- height: r * 2,
29
+ width: width,
30
+ height: height,
21
31
  x: x,
22
32
  y: y
23
33
  };
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
2
+ import type { Ellipse, ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
3
3
  export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipseStyleProps> {
4
- update(parsedStyle: ParsedEllipseStyleProps): {
4
+ update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -8,18 +8,33 @@ var EllipseUpdater =
8
8
  function () {
9
9
  function EllipseUpdater() {}
10
10
 
11
- EllipseUpdater.prototype.update = function (parsedStyle) {
12
- var _a = parsedStyle.rx,
13
- rx = _a === void 0 ? 0 : _a,
14
- _b = parsedStyle.ry,
15
- ry = _b === void 0 ? 0 : _b,
16
- _c = parsedStyle.x,
17
- x = _c === void 0 ? 0 : _c,
18
- _d = parsedStyle.y,
19
- y = _d === void 0 ? 0 : _d;
11
+ EllipseUpdater.prototype.update = function (parsedStyle, object) {
12
+ var rx = parsedStyle.rx,
13
+ ry = parsedStyle.ry,
14
+ _a = parsedStyle.x,
15
+ x = _a === void 0 ? 0 : _a,
16
+ _b = parsedStyle.y,
17
+ y = _b === void 0 ? 0 : _b;
18
+ var rxUnit = rx.unit,
19
+ rxValue = rx.value;
20
+ var ryUnit = ry.unit,
21
+ ryValue = ry.value;
22
+ var width = 0;
23
+ var height = 0;
24
+
25
+ if (rxUnit === '' || rxUnit === 'px') {
26
+ width = rxValue * 2;
27
+ }
28
+
29
+ if (ryUnit === '' || ryUnit === 'px') {
30
+ height = ryValue * 2;
31
+ }
32
+
33
+ object.parsedStyle.rxInPixels = width / 2;
34
+ object.parsedStyle.ryInPixels = height / 2;
20
35
  return {
21
- width: rx * 2,
22
- height: ry * 2,
36
+ width: width,
37
+ height: height,
23
38
  x: x,
24
39
  y: y
25
40
  };
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedImageStyleProps } from '../../display-objects/Image';
2
+ import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
3
3
  export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
4
- update(attributes: ParsedImageStyleProps): {
4
+ update(parsedStyle: ParsedImageStyleProps, object: Image): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -9,32 +9,45 @@ var RectUpdater =
9
9
  function () {
10
10
  function RectUpdater() {}
11
11
 
12
- RectUpdater.prototype.update = function (attributes) {
13
- var img = attributes.img,
14
- _a = attributes.x,
12
+ RectUpdater.prototype.update = function (parsedStyle, object) {
13
+ var img = parsedStyle.img,
14
+ _a = parsedStyle.x,
15
15
  x = _a === void 0 ? 0 : _a,
16
- _b = attributes.y,
16
+ _b = parsedStyle.y,
17
17
  y = _b === void 0 ? 0 : _b,
18
- _c = attributes.width,
19
- width = _c === void 0 ? 0 : _c,
20
- _d = attributes.height,
21
- height = _d === void 0 ? 0 : _d;
22
- var contentWidth;
23
- var contentHeight; // resize with HTMLImageElement's size
18
+ width = parsedStyle.width,
19
+ height = parsedStyle.height;
20
+ var contentWidth = 0;
21
+ var contentHeight = 0;
22
+ var widthUnit = width.unit,
23
+ widthValue = width.value;
24
+ var heightUnit = height.unit,
25
+ heightValue = height.value;
26
+
27
+ if (widthUnit === '' || widthUnit === 'px') {
28
+ contentWidth = widthValue;
29
+ }
30
+
31
+ if (heightUnit === '' || heightUnit === 'px') {
32
+ contentHeight = heightValue;
33
+ } // resize with HTMLImageElement's size
34
+
24
35
 
25
36
  if (img && !isString(img)) {
26
- if (!attributes.width) {
37
+ if (!contentWidth) {
27
38
  contentWidth = img.width;
28
39
  }
29
40
 
30
- if (!attributes.height) {
41
+ if (!contentHeight) {
31
42
  contentHeight = img.height;
32
43
  }
33
44
  }
34
45
 
46
+ object.parsedStyle.widthInPixels = contentWidth;
47
+ object.parsedStyle.heightInPixels = contentHeight;
35
48
  return {
36
- width: contentWidth || width,
37
- height: contentHeight || height,
49
+ width: contentWidth,
50
+ height: contentHeight,
38
51
  x: x,
39
52
  y: y
40
53
  };
@@ -47,6 +60,9 @@ function () {
47
60
  }, {
48
61
  token: GeometryAABBUpdater,
49
62
  named: SHAPE.Image
63
+ }, {
64
+ token: GeometryAABBUpdater,
65
+ named: SHAPE.Group
50
66
  }]
51
67
  })], RectUpdater);
52
68
  return RectUpdater;
@@ -1,7 +1,7 @@
1
1
  import type { DisplayObject } from '../../display-objects/DisplayObject';
2
2
  import type { ParsedBaseStyleProps } from '../../types';
3
3
  export declare const GeometryUpdaterFactory = "GeometryUpdaterFactory";
4
- export declare const GeometryAABBUpdater = "GeometryAABBGenerator";
4
+ export declare const GeometryAABBUpdater = "GeometryAABBUpdater";
5
5
  export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
6
6
  update: (parsedStyle: T, object: DisplayObject) => {
7
7
  width: number;
@@ -1,2 +1,2 @@
1
1
  export var GeometryUpdaterFactory = 'GeometryUpdaterFactory';
2
- export var GeometryAABBUpdater = 'GeometryAABBGenerator';
2
+ export var GeometryAABBUpdater = 'GeometryAABBUpdater';
@@ -7,6 +7,7 @@ import type { Plane } from './Plane';
7
7
  * @see https://github.com/antvis/GWebGPUEngine/issues/3
8
8
  */
9
9
  export declare class AABB {
10
+ static isEmpty(aabb: AABB): boolean;
10
11
  center: vec3;
11
12
  halfExtents: vec3;
12
13
  min: vec3;
package/es/shapes/AABB.js CHANGED
@@ -14,6 +14,10 @@ function () {
14
14
  this.update(center, halfExtents);
15
15
  }
16
16
 
17
+ AABB.isEmpty = function (aabb) {
18
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
19
+ };
20
+
17
21
  AABB.prototype.update = function (center, halfExtents) {
18
22
  this.center = vec3.copy(vec3.create(), center || vec3.create());
19
23
  this.halfExtents = vec3.copy(vec3.create(), halfExtents || vec3.fromValues(0, 0, 0));
@@ -39,6 +43,10 @@ function () {
39
43
  };
40
44
 
41
45
  AABB.prototype.add = function (aabb) {
46
+ if (AABB.isEmpty(aabb)) {
47
+ return;
48
+ }
49
+
42
50
  var tc = this.center;
43
51
  var tcx = tc[0];
44
52
  var tcy = tc[1];
package/es/types.d.ts CHANGED
@@ -110,7 +110,6 @@ export interface BaseStyleProps {
110
110
  */
111
111
  lineDash?: number[] | null;
112
112
  lineDashOffset?: number;
113
- padding?: number[] | number;
114
113
  /**
115
114
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur
116
115
  */
@@ -135,8 +134,6 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
135
134
  points?: ParsedPolylineStyleProps;
136
135
  x?: number;
137
136
  y?: number;
138
- width?: number;
139
- height?: number;
140
137
  /**
141
138
  * x according to definition, eg. Line's x1/x2, Polyline's points
142
139
  */
@@ -5,7 +5,7 @@ export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
5
5
  export declare function getPathArea(pathArray: PathCommand[]): number;
6
6
  export declare function reverseCurve(pathArray: PathCommand[]): PathCommand[];
7
7
  export declare function clonePath(pathArray: PathCommand[]): PathCommand[];
8
- export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["M" | "m", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[];
8
+ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[];
9
9
  /**
10
10
  * convert object to path, should account for:
11
11
  * * transform & origin
package/es/utils/path.js CHANGED
@@ -290,7 +290,7 @@ export function convertToPath(object) {
290
290
  case SHAPE.Circle:
291
291
  {
292
292
  var _b = object.parsedStyle,
293
- r = _b.r,
293
+ r = _b.rInPixels,
294
294
  _c = _b.x,
295
295
  x_1 = _c === void 0 ? 0 : _c,
296
296
  _d = _b.y,
@@ -302,8 +302,8 @@ export function convertToPath(object) {
302
302
  case SHAPE.Ellipse:
303
303
  {
304
304
  var _e = object.parsedStyle,
305
- rx = _e.rx,
306
- ry = _e.ry,
305
+ rx = _e.rxInPixels,
306
+ ry = _e.ryInPixels,
307
307
  _f = _e.x,
308
308
  x_2 = _f === void 0 ? 0 : _f,
309
309
  _g = _e.y,
@@ -320,8 +320,8 @@ export function convertToPath(object) {
320
320
 
321
321
  case SHAPE.Rect:
322
322
  var _h = object.parsedStyle,
323
- width = _h.width,
324
- height = _h.height,
323
+ width = _h.widthInPixels,
324
+ height = _h.heightInPixels,
325
325
  x = _h.x,
326
326
  y = _h.y,
327
327
  radius = _h.radius;
package/lib/Canvas.js CHANGED
@@ -390,6 +390,7 @@ function (_super) {
390
390
  };
391
391
 
392
392
  Canvas.prototype.loadCommonContainerModule = function () {
393
+ this.container.unload(_canvasModule.containerModule);
393
394
  this.container.load(_canvasModule.containerModule, true);
394
395
  };
395
396
 
@@ -19,22 +19,15 @@ var _services = require("./services");
19
19
 
20
20
  var _EventPlugin = require("./plugins/EventPlugin");
21
21
 
22
- var containerModule = (0, _manaSyringe.Module)(function (register, context) {
23
- if (context.container.isBound(_services.RenderingService)) {
24
- // remove rendering plugins
25
- context.container.remove(_services.RenderingPluginContribution);
26
- context.container.remove(_services.RenderingService);
27
- context.container.remove(_FrustumCullingStrategy.FrustumCullingStrategy);
28
- } else {
29
- _manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
30
- cache: false
31
- }); // culling plugin
32
-
33
-
34
- _manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
35
- cache: false
36
- });
37
- } // register built-in rendering plugins
22
+ var containerModule = (0, _manaSyringe.Module)(function (register) {
23
+ _manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
24
+ cache: false
25
+ }); // culling plugin
26
+
27
+
28
+ _manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
29
+ cache: false
30
+ }); // register built-in rendering plugins
38
31
 
39
32
 
40
33
  register(_services.RenderingService);
@@ -1,11 +1,13 @@
1
1
  import type { DisplayObjectConfig } from '../dom/interfaces';
2
2
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface CircleStyleProps extends BaseStyleProps {
5
6
  r: number;
6
7
  }
7
8
  export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
8
- r: number;
9
+ r: ParsedElement;
10
+ rInPixels: number;
9
11
  }
10
12
  export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
11
13
  constructor({ style, ...rest }: DisplayObjectConfig<CircleStyleProps>);
@@ -247,7 +247,9 @@ function (_super) {
247
247
 
248
248
  this.parseStyleProperty(name, value); // @ts-ignore
249
249
 
250
- this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
250
+ var newParsedValue = this.parsedStyle[name]; // @ts-ignore
251
+
252
+ this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
251
253
 
252
254
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
253
255
  this.attributes.clipPathTargets.forEach(function (target) {
@@ -265,7 +267,9 @@ function (_super) {
265
267
  this.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
266
268
  attributeName: name,
267
269
  oldValue: oldValue,
268
- newValue: value
270
+ newValue: value,
271
+ oldParsedValue: oldParsedValue,
272
+ newParsedValue: newParsedValue
269
273
  });
270
274
  }; // #region transformable
271
275
 
@@ -1,13 +1,16 @@
1
1
  import type { DisplayObjectConfig } from '../dom/interfaces';
2
2
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface EllipseStyleProps extends BaseStyleProps {
5
6
  rx: number;
6
7
  ry: number;
7
8
  }
8
9
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
9
- rx: number;
10
- ry: number;
10
+ rx: ParsedElement;
11
+ ry: ParsedElement;
12
+ rxInPixels: number;
13
+ ryInPixels: number;
11
14
  }
12
15
  export declare class Ellipse extends DisplayObject<EllipseStyleProps, ParsedEllipseStyleProps> {
13
16
  constructor({ style, ...rest }: DisplayObjectConfig<EllipseStyleProps>);
@@ -25,7 +25,10 @@ function (_super) {
25
25
 
26
26
  _this = _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.SHAPE.Group,
28
- style: (0, _tslib.__assign)({}, style)
28
+ style: (0, _tslib.__assign)({
29
+ width: 'auto',
30
+ height: 'auto'
31
+ }, style)
29
32
  }, rest)) || this;
30
33
  return _this;
31
34
  }
@@ -2,14 +2,19 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
+ import type { ParsedElement } from '../property-handlers';
5
6
  export interface HTMLStyleProps extends BaseStyleProps {
6
7
  innerHTML: string | HTMLElement;
8
+ width: number;
9
+ height: number;
7
10
  className?: string | string[];
8
11
  style?: string;
9
12
  }
10
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
11
14
  $el: HTMLElement;
12
15
  innerHTML: string | HTMLElement;
16
+ width: ParsedElement;
17
+ height: ParsedElement;
13
18
  className?: string | string[];
14
19
  style?: string;
15
20
  }
@@ -89,7 +89,7 @@ function (_super) {
89
89
 
90
90
  var bounds = this.getBounds();
91
91
 
92
- if (bounds) {
92
+ if (!_shapes.AABB.isEmpty(bounds)) {
93
93
  var localBounds = new _shapes.AABB();
94
94
  localBounds.setFromTransformedAABB(bounds, parentInvert);
95
95
  return localBounds;
@@ -1,15 +1,18 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface ImageStyleProps extends BaseStyleProps {
5
6
  img: string | HTMLImageElement;
6
- width?: number;
7
- height?: number;
7
+ width?: number | string;
8
+ height?: number | string;
8
9
  }
9
10
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
10
11
  img: string | HTMLImageElement;
11
- width?: number;
12
- height?: number;
12
+ width?: ParsedElement;
13
+ height?: ParsedElement;
14
+ widthInPixels?: number;
15
+ heightInPixels?: number;
13
16
  }
14
17
  export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
15
18
  constructor({ style, ...rest }: DisplayObjectConfig<ImageStyleProps>);
@@ -22,7 +22,9 @@ function (_super) {
22
22
  return _super.call(this, (0, _tslib.__assign)({
23
23
  type: _types.SHAPE.Image,
24
24
  style: (0, _tslib.__assign)({
25
- img: ''
25
+ img: '',
26
+ width: 'auto',
27
+ height: 'auto'
26
28
  }, style)
27
29
  }, rest)) || this;
28
30
  }