@antv/g-lite 1.2.3 → 1.2.4

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.
@@ -1,6 +1,5 @@
1
- import type { CSSUnitValue } from '../css';
2
1
  import type { DisplayObjectConfig } from '../dom';
3
- import { AABB } from '../shapes';
2
+ import { AABB, Rectangle } from '../shapes';
4
3
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
5
4
  import { DisplayObject } from './DisplayObject';
6
5
  export interface HTMLStyleProps extends BaseStyleProps {
@@ -11,12 +10,12 @@ export interface HTMLStyleProps extends BaseStyleProps {
11
10
  height?: number | string;
12
11
  }
13
12
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
14
- x: CSSUnitValue;
15
- y: CSSUnitValue;
13
+ x: number;
14
+ y: number;
16
15
  $el: HTMLElement;
17
16
  innerHTML: string | HTMLElement;
18
- width: CSSUnitValue;
19
- height: CSSUnitValue;
17
+ width: number;
18
+ height: number;
20
19
  }
21
20
  /**
22
21
  * HTML container
@@ -34,8 +33,8 @@ export declare class HTML extends DisplayObject<HTMLStyleProps, ParsedHTMLStyleP
34
33
  * override with $el.getBoundingClientRect
35
34
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
36
35
  */
37
- getBoundingClientRect(): DOMRect;
38
- getClientRects(): DOMRect[];
36
+ getBoundingClientRect(): Rectangle;
37
+ getClientRects(): Rectangle[];
39
38
  getBounds(): AABB;
40
39
  getLocalBounds(): AABB;
41
40
  }
package/dist/index.esm.js CHANGED
@@ -13140,7 +13140,13 @@ var HTML = /** @class */ (function (_super) {
13140
13140
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
13141
13141
  */
13142
13142
  HTML.prototype.getBoundingClientRect = function () {
13143
- return this.parsedStyle.$el.getBoundingClientRect();
13143
+ if (this.parsedStyle.$el) {
13144
+ return this.parsedStyle.$el.getBoundingClientRect();
13145
+ }
13146
+ else {
13147
+ var _a = this.parsedStyle, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
13148
+ return new Rectangle(x, y, width, height);
13149
+ }
13144
13150
  };
13145
13151
  HTML.prototype.getClientRects = function () {
13146
13152
  return [this.getBoundingClientRect()];
@@ -13151,18 +13157,11 @@ var HTML = /** @class */ (function (_super) {
13151
13157
  // calc context's offset
13152
13158
  // @ts-ignore
13153
13159
  var canvasRect = (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getContextService().getBoundingClientRect();
13154
- if (canvasRect) {
13155
- var minX = clientRect.left - canvasRect.left;
13156
- var minY = clientRect.top - canvasRect.top;
13157
- var aabb = new AABB();
13158
- // aabb.setMinMax(
13159
- // vec3.fromValues(minX, minY, 0),
13160
- // vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
13161
- // );
13162
- aabb.setMinMax([minX, minY, 0], [minX + clientRect.width, minY + clientRect.height, 0]);
13163
- return aabb;
13164
- }
13165
- return null;
13160
+ var aabb = new AABB();
13161
+ var minX = clientRect.left - ((canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) || 0);
13162
+ var minY = clientRect.top - ((canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) || 0);
13163
+ aabb.setMinMax([minX, minY, 0], [minX + clientRect.width, minY + clientRect.height, 0]);
13164
+ return aabb;
13166
13165
  };
13167
13166
  HTML.prototype.getLocalBounds = function () {
13168
13167
  if (this.parentNode) {