@antv/g-lite 2.0.6 → 2.0.8

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 CHANGED
@@ -67,6 +67,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
67
67
  * is this native event a MouseEvent?
68
68
  */
69
69
  isMouseEvent: (event: InteractivePointerEvent) => event is MouseEvent;
70
+ /**
71
+ * double click speed (ms), default is 200ms
72
+ */
73
+ dblClickSpeed?: CanvasConfig['dblClickSpeed'];
70
74
  /**
71
75
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element
72
76
  */
@@ -414,6 +414,7 @@ export interface ICanvas extends IEventTarget {
414
414
  supportsPointerEvents: boolean;
415
415
  isTouchEvent: (event: InteractivePointerEvent) => event is TouchEvent;
416
416
  isMouseEvent: (event: InteractivePointerEvent) => event is MouseEvent;
417
+ dblClickSpeed?: number;
417
418
  render: () => void;
418
419
  destroy: (destroyScenegraph?: boolean) => void;
419
420
  resize: (width: number, height: number) => void;
package/dist/index.esm.js CHANGED
@@ -1424,6 +1424,39 @@ var Rectangle = /** @class */ (function () {
1424
1424
  this.top = y;
1425
1425
  this.bottom = y + height;
1426
1426
  }
1427
+ /**
1428
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect/fromRect_static
1429
+ */
1430
+ Rectangle.fromRect = function (rect) {
1431
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
1432
+ };
1433
+ /**
1434
+ * will return a new rect instance
1435
+ */
1436
+ Rectangle.applyTransform = function (rect, matrix) {
1437
+ var topLeft = vec4.fromValues(rect.x, rect.y, 0, 1);
1438
+ var topRight = vec4.fromValues(rect.x + rect.width, rect.y, 0, 1);
1439
+ var bottomLeft = vec4.fromValues(rect.x, rect.y + rect.height, 0, 1);
1440
+ var bottomRight = vec4.fromValues(rect.x + rect.width, rect.y + rect.height, 0, 1);
1441
+ var transformedTopLeft = vec4.create();
1442
+ var transformedTopRight = vec4.create();
1443
+ var transformedBottomLeft = vec4.create();
1444
+ var transformedBottomRight = vec4.create();
1445
+ vec4.transformMat4(transformedTopLeft, topLeft, matrix);
1446
+ vec4.transformMat4(transformedTopRight, topRight, matrix);
1447
+ vec4.transformMat4(transformedBottomLeft, bottomLeft, matrix);
1448
+ vec4.transformMat4(transformedBottomRight, bottomRight, matrix);
1449
+ var minX = Math.min(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
1450
+ var minY = Math.min(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
1451
+ var maxX = Math.max(transformedTopLeft[0], transformedTopRight[0], transformedBottomLeft[0], transformedBottomRight[0]);
1452
+ var maxY = Math.max(transformedTopLeft[1], transformedTopRight[1], transformedBottomLeft[1], transformedBottomRight[1]);
1453
+ return Rectangle.fromRect({
1454
+ x: minX,
1455
+ y: minY,
1456
+ width: maxX - minX,
1457
+ height: maxY - minY,
1458
+ });
1459
+ };
1427
1460
  Rectangle.prototype.toJSON = function () { };
1428
1461
  return Rectangle;
1429
1462
  }());
@@ -9263,9 +9296,10 @@ var EventService = /** @class */ (function () {
9263
9296
  timeStamp: now,
9264
9297
  };
9265
9298
  }
9299
+ var canvas = _this.context.renderingContext.root.ownerDocument.defaultView;
9266
9300
  var clickHistory = trackingData.clicksByButton[from.button];
9267
9301
  if (clickHistory.target === clickEvent.target &&
9268
- now - clickHistory.timeStamp < 200) {
9302
+ now - clickHistory.timeStamp < canvas.dblClickSpeed) {
9269
9303
  ++clickHistory.clickCount;
9270
9304
  }
9271
9305
  else {
@@ -13137,7 +13171,11 @@ var HTML = /** @class */ (function (_super) {
13137
13171
  */
13138
13172
  HTML.prototype.getBoundingClientRect = function () {
13139
13173
  if (this.parsedStyle.$el) {
13140
- return this.parsedStyle.$el.getBoundingClientRect();
13174
+ var cameraMatrix = this.ownerDocument.defaultView
13175
+ .getCamera()
13176
+ .getOrthoMatrix();
13177
+ var bBox = this.parsedStyle.$el.getBoundingClientRect();
13178
+ return Rectangle.applyTransform(bBox, mat4.invert(mat4.create(), cameraMatrix));
13141
13179
  }
13142
13180
  else {
13143
13181
  var _a = this.parsedStyle, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
@@ -14937,7 +14975,7 @@ var Canvas = /** @class */ (function (_super) {
14937
14975
  _this.document.defaultView = _this;
14938
14976
  // create registry of custom elements
14939
14977
  _this.customElements = new CustomElementRegistry();
14940
- 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;
14978
+ 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;
14941
14979
  if (!supportsMutipleCanvasesInOneContainer) {
14942
14980
  cleanExistedCanvas(container, _this);
14943
14981
  }
@@ -14985,6 +15023,7 @@ var Canvas = /** @class */ (function (_super) {
14985
15023
  (!_this.supportsPointerEvents ||
14986
15024
  !(event instanceof runtime.globalThis.PointerEvent)));
14987
15025
  });
15026
+ _this.dblClickSpeed = dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200;
14988
15027
  _this.initRenderingContext({
14989
15028
  container: container,
14990
15029
  canvas: canvas,
@@ -15264,13 +15303,13 @@ var Canvas = /** @class */ (function (_super) {
15264
15303
  else {
15265
15304
  _this.dispatchEvent(new CustomEvent(CanvasEvent.READY));
15266
15305
  }
15267
- if (_this.readyPromise) {
15268
- _this.resolveReadyPromise();
15269
- }
15270
15306
  }
15271
15307
  else {
15272
15308
  _this.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED));
15273
15309
  }
15310
+ if (_this.readyPromise) {
15311
+ _this.resolveReadyPromise();
15312
+ }
15274
15313
  if (!firstContentfullPaint) {
15275
15314
  _this.getRoot().forEach(function (node) {
15276
15315
  var renderable = node.renderable;