@antv/g-lite 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8362,6 +8362,21 @@ var GroupUpdater = /** @class */ (function () {
8362
8362
  return GroupUpdater;
8363
8363
  }());
8364
8364
 
8365
+ var HTMLUpdater = /** @class */ (function () {
8366
+ function HTMLUpdater() {
8367
+ }
8368
+ HTMLUpdater.prototype.update = function (parsedStyle, object) {
8369
+ var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
8370
+ return {
8371
+ cx: x + width / 2,
8372
+ cy: y + height / 2,
8373
+ hwidth: width / 2,
8374
+ hheight: height / 2,
8375
+ };
8376
+ };
8377
+ return HTMLUpdater;
8378
+ }());
8379
+
8365
8380
  function isFederatedEvent(value) {
8366
8381
  return !!value.type;
8367
8382
  }
@@ -11676,7 +11691,7 @@ var geometryUpdaterFactory = (function () {
11676
11691
  _a[exports.Shape.POLYLINE] = polylineUpdater,
11677
11692
  _a[exports.Shape.POLYGON] = polylineUpdater,
11678
11693
  _a[exports.Shape.PATH] = new PathUpdater(),
11679
- _a[exports.Shape.HTML] = null,
11694
+ _a[exports.Shape.HTML] = new HTMLUpdater(),
11680
11695
  _a[exports.Shape.MESH] = null,
11681
11696
  _a;
11682
11697
  })();
@@ -13189,35 +13204,36 @@ var HTML = /** @class */ (function (_super) {
13189
13204
  /**
13190
13205
  * override with $el.getBoundingClientRect
13191
13206
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
13192
- */
13193
- HTML.prototype.getBoundingClientRect = function () {
13194
- if (this.parsedStyle.$el) {
13195
- var cameraMatrix = this.ownerDocument.defaultView
13196
- .getCamera()
13197
- .getOrthoMatrix();
13198
- var bBox = this.parsedStyle.$el.getBoundingClientRect();
13199
- return Rectangle.applyTransform(bBox, glMatrix.mat4.invert(glMatrix.mat4.create(), cameraMatrix));
13200
- }
13201
- else {
13202
- var _a = this.parsedStyle, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
13203
- return new Rectangle(x, y, width, height);
13204
- }
13205
- };
13207
+ *
13208
+ * ! The calculation logic of the html element should be consistent with that of the canvas element
13209
+ */
13210
+ // getBoundingClientRect(): Rectangle {
13211
+ // if (this.parsedStyle.$el) {
13212
+ // return this.parsedStyle.$el.getBoundingClientRect();
13213
+ // } else {
13214
+ // const { x, y, width, height } = this.parsedStyle;
13215
+ // return new Rectangle(x, y, width, height);
13216
+ // }
13217
+ // }
13206
13218
  HTML.prototype.getClientRects = function () {
13207
13219
  return [this.getBoundingClientRect()];
13208
13220
  };
13209
- HTML.prototype.getBounds = function () {
13210
- var _a, _b;
13211
- var clientRect = this.getBoundingClientRect();
13212
- // calc context's offset
13213
- // @ts-ignore
13214
- var canvasRect = (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getContextService().getBoundingClientRect();
13215
- var aabb = new AABB();
13216
- var minX = clientRect.left - ((canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) || 0);
13217
- var minY = clientRect.top - ((canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) || 0);
13218
- aabb.setMinMax([minX, minY, 0], [minX + clientRect.width, minY + clientRect.height, 0]);
13219
- return aabb;
13220
- };
13221
+ // getBounds() {
13222
+ // const clientRect = this.getBoundingClientRect();
13223
+ // // calc context's offset
13224
+ // // @ts-ignore
13225
+ // const canvasRect = this.ownerDocument?.defaultView
13226
+ // ?.getContextService()
13227
+ // .getBoundingClientRect();
13228
+ // const aabb = new AABB();
13229
+ // const minX = clientRect.left - (canvasRect?.left || 0);
13230
+ // const minY = clientRect.top - (canvasRect?.top || 0);
13231
+ // aabb.setMinMax(
13232
+ // [minX, minY, 0],
13233
+ // [minX + clientRect.width, minY + clientRect.height, 0],
13234
+ // );
13235
+ // return aabb;
13236
+ // }
13221
13237
  HTML.prototype.getLocalBounds = function () {
13222
13238
  if (this.parentNode) {
13223
13239
  var parentInvert = glMatrix.mat4.invert(glMatrix.mat4.create(), this.parentNode.getWorldTransform());
@@ -15499,6 +15515,7 @@ exports.Frustum = Frustum;
15499
15515
  exports.Group = Group;
15500
15516
  exports.GroupUpdater = GroupUpdater;
15501
15517
  exports.HTML = HTML;
15518
+ exports.HTMLUpdater = HTMLUpdater;
15502
15519
  exports.Image = Image;
15503
15520
  exports.Line = Line;
15504
15521
  exports.LineUpdater = LineUpdater;