@antv/g-lite 2.0.7 → 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/Canvas.d.ts +4 -0
- package/dist/display-objects/HTML.d.ts +4 -4
- package/dist/dom/interfaces.d.ts +1 -0
- package/dist/index.esm.js +81 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +81 -25
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/services/aabb/HTMLUpdater.d.ts +10 -0
- package/dist/services/aabb/index.d.ts +1 -0
- package/dist/shapes/Rectangle.d.ts +16 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1445,6 +1445,39 @@ var Rectangle = /** @class */ (function () {
|
|
|
1445
1445
|
this.top = y;
|
|
1446
1446
|
this.bottom = y + height;
|
|
1447
1447
|
}
|
|
1448
|
+
/**
|
|
1449
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect/fromRect_static
|
|
1450
|
+
*/
|
|
1451
|
+
Rectangle.fromRect = function (rect) {
|
|
1452
|
+
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
|
|
1453
|
+
};
|
|
1454
|
+
/**
|
|
1455
|
+
* will return a new rect instance
|
|
1456
|
+
*/
|
|
1457
|
+
Rectangle.applyTransform = function (rect, matrix) {
|
|
1458
|
+
var topLeft = glMatrix.vec4.fromValues(rect.x, rect.y, 0, 1);
|
|
1459
|
+
var topRight = glMatrix.vec4.fromValues(rect.x + rect.width, rect.y, 0, 1);
|
|
1460
|
+
var bottomLeft = glMatrix.vec4.fromValues(rect.x, rect.y + rect.height, 0, 1);
|
|
1461
|
+
var bottomRight = glMatrix.vec4.fromValues(rect.x + rect.width, rect.y + rect.height, 0, 1);
|
|
1462
|
+
var transformedTopLeft = glMatrix.vec4.create();
|
|
1463
|
+
var transformedTopRight = glMatrix.vec4.create();
|
|
1464
|
+
var transformedBottomLeft = glMatrix.vec4.create();
|
|
1465
|
+
var transformedBottomRight = glMatrix.vec4.create();
|
|
1466
|
+
glMatrix.vec4.transformMat4(transformedTopLeft, topLeft, matrix);
|
|
1467
|
+
glMatrix.vec4.transformMat4(transformedTopRight, topRight, matrix);
|
|
1468
|
+
glMatrix.vec4.transformMat4(transformedBottomLeft, bottomLeft, matrix);
|
|
1469
|
+
glMatrix.vec4.transformMat4(transformedBottomRight, bottomRight, matrix);
|
|
1470
|
+
var minX = Math.min(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1471
|
+
var minY = Math.min(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1472
|
+
var maxX = Math.max(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
|
|
1473
|
+
var maxY = Math.max(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
|
|
1474
|
+
return Rectangle.fromRect({
|
|
1475
|
+
x: minX,
|
|
1476
|
+
y: minY,
|
|
1477
|
+
width: maxX - minX,
|
|
1478
|
+
height: maxY - minY,
|
|
1479
|
+
});
|
|
1480
|
+
};
|
|
1448
1481
|
Rectangle.prototype.toJSON = function () { };
|
|
1449
1482
|
return Rectangle;
|
|
1450
1483
|
}());
|
|
@@ -8329,6 +8362,21 @@ var GroupUpdater = /** @class */ (function () {
|
|
|
8329
8362
|
return GroupUpdater;
|
|
8330
8363
|
}());
|
|
8331
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
|
+
|
|
8332
8380
|
function isFederatedEvent(value) {
|
|
8333
8381
|
return !!value.type;
|
|
8334
8382
|
}
|
|
@@ -9284,9 +9332,10 @@ var EventService = /** @class */ (function () {
|
|
|
9284
9332
|
timeStamp: now,
|
|
9285
9333
|
};
|
|
9286
9334
|
}
|
|
9335
|
+
var canvas = _this.context.renderingContext.root.ownerDocument.defaultView;
|
|
9287
9336
|
var clickHistory = trackingData.clicksByButton[from.button];
|
|
9288
9337
|
if (clickHistory.target === clickEvent.target &&
|
|
9289
|
-
now - clickHistory.timeStamp <
|
|
9338
|
+
now - clickHistory.timeStamp < canvas.dblClickSpeed) {
|
|
9290
9339
|
++clickHistory.clickCount;
|
|
9291
9340
|
}
|
|
9292
9341
|
else {
|
|
@@ -11642,7 +11691,7 @@ var geometryUpdaterFactory = (function () {
|
|
|
11642
11691
|
_a[exports.Shape.POLYLINE] = polylineUpdater,
|
|
11643
11692
|
_a[exports.Shape.POLYGON] = polylineUpdater,
|
|
11644
11693
|
_a[exports.Shape.PATH] = new PathUpdater(),
|
|
11645
|
-
_a[exports.Shape.HTML] =
|
|
11694
|
+
_a[exports.Shape.HTML] = new HTMLUpdater(),
|
|
11646
11695
|
_a[exports.Shape.MESH] = null,
|
|
11647
11696
|
_a;
|
|
11648
11697
|
})();
|
|
@@ -13155,31 +13204,36 @@ var HTML = /** @class */ (function (_super) {
|
|
|
13155
13204
|
/**
|
|
13156
13205
|
* override with $el.getBoundingClientRect
|
|
13157
13206
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
}
|
|
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
|
+
// }
|
|
13168
13218
|
HTML.prototype.getClientRects = function () {
|
|
13169
13219
|
return [this.getBoundingClientRect()];
|
|
13170
13220
|
};
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
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
|
+
// }
|
|
13183
13237
|
HTML.prototype.getLocalBounds = function () {
|
|
13184
13238
|
if (this.parentNode) {
|
|
13185
13239
|
var parentInvert = glMatrix.mat4.invert(glMatrix.mat4.create(), this.parentNode.getWorldTransform());
|
|
@@ -14958,7 +15012,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
14958
15012
|
_this.document.defaultView = _this;
|
|
14959
15013
|
// create registry of custom elements
|
|
14960
15014
|
_this.customElements = new CustomElementRegistry();
|
|
14961
|
-
var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent;
|
|
15015
|
+
var container = config.container, canvas = config.canvas, offscreenCanvas = config.offscreenCanvas, width = config.width, height = config.height, devicePixelRatio = config.devicePixelRatio, renderer = config.renderer, background = config.background, cursor = config.cursor, document = config.document, requestAnimationFrame = config.requestAnimationFrame, cancelAnimationFrame = config.cancelAnimationFrame, createImage = config.createImage, supportsPointerEvents = config.supportsPointerEvents, supportsTouchEvents = config.supportsTouchEvents, supportsCSSTransform = config.supportsCSSTransform, supportsMutipleCanvasesInOneContainer = config.supportsMutipleCanvasesInOneContainer, useNativeClickEvent = config.useNativeClickEvent, alwaysTriggerPointerEventOnCanvas = config.alwaysTriggerPointerEventOnCanvas, isTouchEvent = config.isTouchEvent, isMouseEvent = config.isMouseEvent, dblClickSpeed = config.dblClickSpeed;
|
|
14962
15016
|
if (!supportsMutipleCanvasesInOneContainer) {
|
|
14963
15017
|
cleanExistedCanvas(container, _this);
|
|
14964
15018
|
}
|
|
@@ -15006,6 +15060,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15006
15060
|
(!_this.supportsPointerEvents ||
|
|
15007
15061
|
!(event instanceof runtime.globalThis.PointerEvent)));
|
|
15008
15062
|
});
|
|
15063
|
+
_this.dblClickSpeed = dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200;
|
|
15009
15064
|
_this.initRenderingContext({
|
|
15010
15065
|
container: container,
|
|
15011
15066
|
canvas: canvas,
|
|
@@ -15460,6 +15515,7 @@ exports.Frustum = Frustum;
|
|
|
15460
15515
|
exports.Group = Group;
|
|
15461
15516
|
exports.GroupUpdater = GroupUpdater;
|
|
15462
15517
|
exports.HTML = HTML;
|
|
15518
|
+
exports.HTMLUpdater = HTMLUpdater;
|
|
15463
15519
|
exports.Image = Image;
|
|
15464
15520
|
exports.Line = Line;
|
|
15465
15521
|
exports.LineUpdater = LineUpdater;
|