@antv/g-lite 1.0.48 → 1.0.50

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
@@ -2032,9 +2032,7 @@ function normalize(out, mat) {
2032
2032
  // Cannot normalize.
2033
2033
  if (m44 === 0) return false;
2034
2034
  var scale = 1 / m44;
2035
- for (var i = 0; i < 16; i++) {
2036
- out[i] = mat[i] * scale;
2037
- }
2035
+ for (var i = 0; i < 16; i++) out[i] = mat[i] * scale;
2038
2036
  return true;
2039
2037
  }
2040
2038
  //gets upper-left of a 4x4 matrix into a 3x3 of vectors
@@ -3729,7 +3727,7 @@ var HookCodeFactory = /*#__PURE__*/function () {
3729
3727
  var code = '';
3730
3728
  var current = onDone;
3731
3729
  var unrollCounter = 0;
3732
- var _loop = function _loop(j) {
3730
+ var _loop = function _loop() {
3733
3731
  var i = j;
3734
3732
  var unroll = current !== onDone && (_this2.options.taps[i].type !== 'sync' || unrollCounter++ > 20);
3735
3733
  if (unroll) {
@@ -3761,7 +3759,7 @@ var HookCodeFactory = /*#__PURE__*/function () {
3761
3759
  };
3762
3760
  };
3763
3761
  for (var j = this.options.taps.length - 1; j >= 0; j--) {
3764
- _loop(j);
3762
+ _loop();
3765
3763
  }
3766
3764
  code += current();
3767
3765
  return code;
@@ -4286,12 +4284,10 @@ function spaceColorStops(colorStops) {
4286
4284
  // support '%' & 'px'
4287
4285
  var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
4288
4286
  if (!util.isNil(offset) && !util.isNil(previousOffset)) {
4289
- for (var j = 1; j < i - previousIndex; j++) {
4290
- colorStops[previousIndex + j].length = {
4291
- type: '%',
4292
- value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
4293
- };
4294
- }
4287
+ for (var j = 1; j < i - previousIndex; j++) colorStops[previousIndex + j].length = {
4288
+ type: '%',
4289
+ value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
4290
+ };
4295
4291
  previousIndex = i;
4296
4292
  previousOffset = Number(offset);
4297
4293
  }
@@ -4568,9 +4564,7 @@ function mergeColors(left, right) {
4568
4564
  return [[Number(left.r), Number(left.g), Number(left.b), Number(left.alpha)], [Number(right.r), Number(right.g), Number(right.b), Number(right.alpha)], function (color) {
4569
4565
  var rgba = color.slice();
4570
4566
  if (rgba[3]) {
4571
- for (var i = 0; i < 3; i++) {
4572
- rgba[i] = Math.round(util.clamp(rgba[i], 0, 255));
4573
- }
4567
+ for (var i = 0; i < 3; i++) rgba[i] = Math.round(util.clamp(rgba[i], 0, 255));
4574
4568
  }
4575
4569
  rgba[3] = util.clamp(rgba[3], 0, 1);
4576
4570
  return "rgba(" + rgba.join(',') + ")";
@@ -5364,7 +5358,7 @@ function mergeTransforms(left, right, target) {
5364
5358
  left = right;
5365
5359
  right = [];
5366
5360
  }
5367
- var _loop = function _loop(i) {
5361
+ var _loop = function _loop() {
5368
5362
  var _left$i = left[i],
5369
5363
  type = _left$i.t,
5370
5364
  args = _left$i.d;
@@ -5385,7 +5379,7 @@ function mergeTransforms(left, right, target) {
5385
5379
  });
5386
5380
  };
5387
5381
  for (var i = 0; i < left.length; i++) {
5388
- _loop(i);
5382
+ _loop();
5389
5383
  }
5390
5384
  }
5391
5385
  var leftResult = [];
@@ -6287,6 +6281,9 @@ var Rectangle = /*#__PURE__*/function () {
6287
6281
 
6288
6282
  var CSSPropertyPath = /*#__PURE__*/function () {
6289
6283
  function CSSPropertyPath() {
6284
+ /**
6285
+ * path2Curve
6286
+ */
6290
6287
  this.parser = parsePath;
6291
6288
  this.parserWithCSSDisabled = parsePath;
6292
6289
  this.mixer = mergePaths;
@@ -6534,26 +6531,83 @@ var FederatedEvent = /*#__PURE__*/function () {
6534
6531
  * within the boundary's jurisdiction.
6535
6532
  */
6536
6533
  function FederatedEvent(manager) {
6534
+ /**
6535
+ * The type of event, supports the following:
6536
+ * * pointerdown
6537
+ * * touchstart
6538
+ * * mousedown
6539
+ * * rightdown
6540
+ * * ...
6541
+ */
6537
6542
  this.type = void 0;
6543
+ /**
6544
+ * The propagation phase.
6545
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
6546
+ */
6538
6547
  this.eventPhase = FederatedEvent.prototype.NONE;
6548
+ /**
6549
+ * can be used to implement event delegation
6550
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/target
6551
+ */
6539
6552
  this.target = void 0;
6553
+ /**
6554
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/bubbles
6555
+ */
6540
6556
  this.bubbles = true;
6557
+ /**
6558
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/cancelBubble
6559
+ */
6541
6560
  this.cancelBubble = true;
6561
+ /**
6562
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable
6563
+ */
6542
6564
  this.cancelable = false;
6565
+ /** the event target when listeners binded */
6543
6566
  this.currentTarget = void 0;
6567
+ /** Flags whether the default response of the user agent was prevent through this event. */
6544
6568
  this.defaultPrevented = false;
6569
+ /**
6570
+ * timestamp when the event created
6571
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/timeStamp
6572
+ */
6545
6573
  this.timeStamp = void 0;
6574
+ /**
6575
+ * the original event.
6576
+ */
6546
6577
  this.nativeEvent = void 0;
6578
+ /** The original event that caused this event, if any. */
6547
6579
  this.originalEvent = void 0;
6580
+ /** Flags whether propagation was stopped. */
6548
6581
  this.propagationStopped = false;
6582
+ /** Flags whether propagation was immediately stopped. */
6549
6583
  this.propagationImmediatelyStopped = false;
6550
6584
  this.manager = void 0;
6585
+ /** Event-specific detail */
6551
6586
  this.detail = void 0;
6587
+ /**
6588
+ * The coordinates of the evnet relative to the nearest DOM layer.
6589
+ * This is a non-standard property.
6590
+ */
6552
6591
  this.layer = new Point();
6592
+ /**
6593
+ * The coordinates of the event relative to the DOM document.
6594
+ * This is a non-standard property.
6595
+ * relative to the DOM document.
6596
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
6597
+ */
6553
6598
  this.page = new Point();
6599
+ /**
6600
+ * relative to Canvas, origin is left-top
6601
+ */
6554
6602
  this.canvas = new Point();
6603
+ /**
6604
+ * relative to Viewport, account for Camera
6605
+ */
6555
6606
  this.viewport = new Point();
6556
6607
  this.path = void 0;
6608
+ /**
6609
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
6610
+ */
6557
6611
  this.view = void 0;
6558
6612
  this.which = void 0;
6559
6613
  this.returnValue = void 0;
@@ -6603,10 +6657,7 @@ var FederatedEvent = /*#__PURE__*/function () {
6603
6657
  */;
6604
6658
  _proto.stopPropagation = function stopPropagation() {
6605
6659
  this.propagationStopped = true;
6606
- }
6607
- /**
6608
- * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
6609
- */;
6660
+ };
6610
6661
  /**
6611
6662
  * added for compatibility with DOM Event,
6612
6663
  * deprecated props and methods
@@ -6619,25 +6670,12 @@ var FederatedEvent = /*#__PURE__*/function () {
6619
6670
  _createClass(FederatedEvent, [{
6620
6671
  key: "name",
6621
6672
  get:
6622
- /**
6623
- * The type of event, supports the following:
6624
- * * pointerdown
6625
- * * touchstart
6626
- * * mousedown
6627
- * * rightdown
6628
- * * ...
6629
- */
6630
-
6631
6673
  /**
6632
6674
  * @deprecated
6633
6675
  */
6634
6676
  function get() {
6635
6677
  return this.type;
6636
6678
  }
6637
- /**
6638
- * The propagation phase.
6639
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/eventPhase
6640
- */
6641
6679
  }, {
6642
6680
  key: "layerX",
6643
6681
  get: function get() {
@@ -6648,12 +6686,6 @@ var FederatedEvent = /*#__PURE__*/function () {
6648
6686
  get: function get() {
6649
6687
  return this.layer.y;
6650
6688
  }
6651
- /**
6652
- * The coordinates of the event relative to the DOM document.
6653
- * This is a non-standard property.
6654
- * relative to the DOM document.
6655
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX
6656
- */
6657
6689
  }, {
6658
6690
  key: "pageX",
6659
6691
  get: function get() {
@@ -6664,9 +6696,6 @@ var FederatedEvent = /*#__PURE__*/function () {
6664
6696
  get: function get() {
6665
6697
  return this.page.y;
6666
6698
  }
6667
- /**
6668
- * relative to Canvas, origin is left-top
6669
- */
6670
6699
  }, {
6671
6700
  key: "x",
6672
6701
  get: function get() {
@@ -6687,9 +6716,6 @@ var FederatedEvent = /*#__PURE__*/function () {
6687
6716
  get: function get() {
6688
6717
  return this.canvas.y;
6689
6718
  }
6690
- /**
6691
- * relative to Viewport, account for Camera
6692
- */
6693
6719
  }, {
6694
6720
  key: "viewportX",
6695
6721
  get: function get() {
@@ -6744,6 +6770,9 @@ var DELEGATION_SPLITTER = ':';
6744
6770
  */
6745
6771
  var EventTarget = /*#__PURE__*/function () {
6746
6772
  function EventTarget() {
6773
+ /**
6774
+ * event emitter
6775
+ */
6747
6776
  this.emitter = new EventEmitter__default['default']();
6748
6777
  }
6749
6778
  var _proto = EventTarget.prototype;
@@ -6886,13 +6915,44 @@ var Node = /*#__PURE__*/function (_EventTarget) {
6886
6915
  }
6887
6916
  _this = _EventTarget.call.apply(_EventTarget, [this].concat(args)) || this;
6888
6917
  _this.shadow = false;
6918
+ /**
6919
+ * points to canvas.document
6920
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument
6921
+ */
6889
6922
  _this.ownerDocument = null;
6923
+ /**
6924
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/isConnected
6925
+ * @example
6926
+ circle.isConnected; // false
6927
+ canvas.appendChild(circle);
6928
+ circle.isConnected; // true
6929
+ */
6890
6930
  _this.isConnected = false;
6931
+ /**
6932
+ * Returns node's node document's document base URL.
6933
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node
6934
+ */
6891
6935
  _this.baseURI = '';
6936
+ /**
6937
+ * Returns the children.
6938
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes
6939
+ */
6892
6940
  _this.childNodes = [];
6941
+ /**
6942
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
6943
+ */
6893
6944
  _this.nodeType = 0;
6945
+ /**
6946
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeName
6947
+ */
6894
6948
  _this.nodeName = '';
6949
+ /**
6950
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeValue
6951
+ */
6895
6952
  _this.nodeValue = null;
6953
+ /**
6954
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
6955
+ */
6896
6956
  _this.parentNode = null;
6897
6957
  return _this;
6898
6958
  }
@@ -6939,10 +6999,7 @@ var Node = /*#__PURE__*/function (_EventTarget) {
6939
6999
  };
6940
7000
  _proto.isSameNode = function isSameNode(otherNode) {
6941
7001
  return this.isEqualNode(otherNode);
6942
- }
6943
- /**
6944
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
6945
- */;
7002
+ };
6946
7003
  /**
6947
7004
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
6948
7005
  * @see https://github.com/b-fuze/deno-dom/blob/master/src/dom/node.ts#L338
@@ -7117,11 +7174,30 @@ var Node = /*#__PURE__*/function (_EventTarget) {
7117
7174
  }]);
7118
7175
  return Node;
7119
7176
  }(EventTarget);
7177
+ /**
7178
+ * Both nodes are in different documents or different trees in the same document.
7179
+ */
7120
7180
  Node.DOCUMENT_POSITION_DISCONNECTED = 1;
7181
+ /**
7182
+ * otherNode precedes the node in either a pre-order depth-first traversal
7183
+ * of a tree containing both (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
7184
+ */
7121
7185
  Node.DOCUMENT_POSITION_PRECEDING = 2;
7186
+ /**
7187
+ * otherNode follows the node in either a pre-order depth-first traversal of a tree containing both (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
7188
+ */
7122
7189
  Node.DOCUMENT_POSITION_FOLLOWING = 4;
7190
+ /**
7191
+ * otherNode is an ancestor of the node.
7192
+ */
7123
7193
  Node.DOCUMENT_POSITION_CONTAINS = 8;
7194
+ /**
7195
+ * otherNode is a descendant of the node.
7196
+ */
7124
7197
  Node.DOCUMENT_POSITION_CONTAINED_BY = 16;
7198
+ /**
7199
+ * The result relies upon arbitrary and/or implementation-specific behavior and is not guaranteed to be portable.
7200
+ */
7125
7201
  Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
7126
7202
 
7127
7203
  /**
@@ -7134,8 +7210,19 @@ var Document = /*#__PURE__*/function (_Node) {
7134
7210
  function Document() {
7135
7211
  var _this;
7136
7212
  _this = _Node.call(this) || this;
7213
+ /**
7214
+ * only document has defaultView, points to canvas,
7215
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
7216
+ */
7137
7217
  _this.defaultView = null;
7218
+ /**
7219
+ * the root element of document, eg. <html>
7220
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement
7221
+ */
7138
7222
  _this.documentElement = void 0;
7223
+ /**
7224
+ * document.timeline in WAAPI
7225
+ */
7139
7226
  _this.timeline = void 0;
7140
7227
  _this.ownerDocument = null;
7141
7228
  _this.nodeName = 'document';
@@ -7273,45 +7360,43 @@ var Document = /*#__PURE__*/function (_Node) {
7273
7360
  var _elementFromPoint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(x, y) {
7274
7361
  var _this$defaultView$can2, viewportX, viewportY, _this$defaultView$get3, width, height, _this$defaultView$vie2, clientX, clientY, _yield$this$defaultVi, picked;
7275
7362
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7276
- while (1) {
7277
- switch (_context.prev = _context.next) {
7278
- case 0:
7279
- _this$defaultView$can2 = this.defaultView.canvas2Viewport({
7363
+ while (1) switch (_context.prev = _context.next) {
7364
+ case 0:
7365
+ _this$defaultView$can2 = this.defaultView.canvas2Viewport({
7366
+ x: x,
7367
+ y: y
7368
+ }), viewportX = _this$defaultView$can2.x, viewportY = _this$defaultView$can2.y;
7369
+ _this$defaultView$get3 = this.defaultView.getConfig(), width = _this$defaultView$get3.width, height = _this$defaultView$get3.height; // outside canvas' viewport
7370
+ if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
7371
+ _context.next = 4;
7372
+ break;
7373
+ }
7374
+ return _context.abrupt("return", null);
7375
+ case 4:
7376
+ _this$defaultView$vie2 = this.defaultView.viewport2Client({
7377
+ x: viewportX,
7378
+ y: viewportY
7379
+ }), clientX = _this$defaultView$vie2.x, clientY = _this$defaultView$vie2.y;
7380
+ _context.next = 7;
7381
+ return this.defaultView.getRenderingService().hooks.pick.promise({
7382
+ topmost: true,
7383
+ position: {
7280
7384
  x: x,
7281
- y: y
7282
- }), viewportX = _this$defaultView$can2.x, viewportY = _this$defaultView$can2.y;
7283
- _this$defaultView$get3 = this.defaultView.getConfig(), width = _this$defaultView$get3.width, height = _this$defaultView$get3.height; // outside canvas' viewport
7284
- if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
7285
- _context.next = 4;
7286
- break;
7287
- }
7288
- return _context.abrupt("return", null);
7289
- case 4:
7290
- _this$defaultView$vie2 = this.defaultView.viewport2Client({
7291
- x: viewportX,
7292
- y: viewportY
7293
- }), clientX = _this$defaultView$vie2.x, clientY = _this$defaultView$vie2.y;
7294
- _context.next = 7;
7295
- return this.defaultView.getRenderingService().hooks.pick.promise({
7296
- topmost: true,
7297
- position: {
7298
- x: x,
7299
- y: y,
7300
- viewportX: viewportX,
7301
- viewportY: viewportY,
7302
- clientX: clientX,
7303
- clientY: clientY
7304
- },
7305
- picked: []
7306
- });
7307
- case 7:
7308
- _yield$this$defaultVi = _context.sent;
7309
- picked = _yield$this$defaultVi.picked;
7310
- return _context.abrupt("return", picked && picked[0] || this.documentElement);
7311
- case 10:
7312
- case "end":
7313
- return _context.stop();
7314
- }
7385
+ y: y,
7386
+ viewportX: viewportX,
7387
+ viewportY: viewportY,
7388
+ clientX: clientX,
7389
+ clientY: clientY
7390
+ },
7391
+ picked: []
7392
+ });
7393
+ case 7:
7394
+ _yield$this$defaultVi = _context.sent;
7395
+ picked = _yield$this$defaultVi.picked;
7396
+ return _context.abrupt("return", picked && picked[0] || this.documentElement);
7397
+ case 10:
7398
+ case "end":
7399
+ return _context.stop();
7315
7400
  }
7316
7401
  }, _callee, this);
7317
7402
  }));
@@ -7369,48 +7454,46 @@ var Document = /*#__PURE__*/function (_Node) {
7369
7454
  var _elementsFromPoint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(x, y) {
7370
7455
  var _this$defaultView$can4, viewportX, viewportY, _this$defaultView$get6, width, height, _this$defaultView$vie4, clientX, clientY, _yield$this$defaultVi2, picked;
7371
7456
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7372
- while (1) {
7373
- switch (_context2.prev = _context2.next) {
7374
- case 0:
7375
- _this$defaultView$can4 = this.defaultView.canvas2Viewport({
7457
+ while (1) switch (_context2.prev = _context2.next) {
7458
+ case 0:
7459
+ _this$defaultView$can4 = this.defaultView.canvas2Viewport({
7460
+ x: x,
7461
+ y: y
7462
+ }), viewportX = _this$defaultView$can4.x, viewportY = _this$defaultView$can4.y;
7463
+ _this$defaultView$get6 = this.defaultView.getConfig(), width = _this$defaultView$get6.width, height = _this$defaultView$get6.height; // outside canvas' viewport
7464
+ if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
7465
+ _context2.next = 4;
7466
+ break;
7467
+ }
7468
+ return _context2.abrupt("return", []);
7469
+ case 4:
7470
+ _this$defaultView$vie4 = this.defaultView.viewport2Client({
7471
+ x: viewportX,
7472
+ y: viewportY
7473
+ }), clientX = _this$defaultView$vie4.x, clientY = _this$defaultView$vie4.y;
7474
+ _context2.next = 7;
7475
+ return this.defaultView.getRenderingService().hooks.pick.promise({
7476
+ topmost: false,
7477
+ position: {
7376
7478
  x: x,
7377
- y: y
7378
- }), viewportX = _this$defaultView$can4.x, viewportY = _this$defaultView$can4.y;
7379
- _this$defaultView$get6 = this.defaultView.getConfig(), width = _this$defaultView$get6.width, height = _this$defaultView$get6.height; // outside canvas' viewport
7380
- if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
7381
- _context2.next = 4;
7382
- break;
7383
- }
7384
- return _context2.abrupt("return", []);
7385
- case 4:
7386
- _this$defaultView$vie4 = this.defaultView.viewport2Client({
7387
- x: viewportX,
7388
- y: viewportY
7389
- }), clientX = _this$defaultView$vie4.x, clientY = _this$defaultView$vie4.y;
7390
- _context2.next = 7;
7391
- return this.defaultView.getRenderingService().hooks.pick.promise({
7392
- topmost: false,
7393
- position: {
7394
- x: x,
7395
- y: y,
7396
- viewportX: viewportX,
7397
- viewportY: viewportY,
7398
- clientX: clientX,
7399
- clientY: clientY
7400
- },
7401
- picked: []
7402
- });
7403
- case 7:
7404
- _yield$this$defaultVi2 = _context2.sent;
7405
- picked = _yield$this$defaultVi2.picked;
7406
- if (picked[picked.length - 1] !== this.documentElement) {
7407
- picked.push(this.documentElement);
7408
- }
7409
- return _context2.abrupt("return", picked);
7410
- case 11:
7411
- case "end":
7412
- return _context2.stop();
7413
- }
7479
+ y: y,
7480
+ viewportX: viewportX,
7481
+ viewportY: viewportY,
7482
+ clientX: clientX,
7483
+ clientY: clientY
7484
+ },
7485
+ picked: []
7486
+ });
7487
+ case 7:
7488
+ _yield$this$defaultVi2 = _context2.sent;
7489
+ picked = _yield$this$defaultVi2.picked;
7490
+ if (picked[picked.length - 1] !== this.documentElement) {
7491
+ picked.push(this.documentElement);
7492
+ }
7493
+ return _context2.abrupt("return", picked);
7494
+ case 11:
7495
+ case "end":
7496
+ return _context2.stop();
7414
7497
  }
7415
7498
  }, _callee2, this);
7416
7499
  }));
@@ -7488,10 +7571,6 @@ var Document = /*#__PURE__*/function (_Node) {
7488
7571
  get: function get() {
7489
7572
  return this.lastChild;
7490
7573
  }
7491
- /**
7492
- * only document has defaultView, points to canvas,
7493
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
7494
- */
7495
7574
  }]);
7496
7575
  return Document;
7497
7576
  }(Node);
@@ -7593,6 +7672,9 @@ var Element = /*#__PURE__*/function (_Node) {
7593
7672
  args[_key] = arguments[_key];
7594
7673
  }
7595
7674
  _this = _Node.call.apply(_Node, [this].concat(args)) || this;
7675
+ /**
7676
+ * Unique id.
7677
+ */
7596
7678
  _this.entity = entityCounter++;
7597
7679
  _this.renderable = {
7598
7680
  bounds: undefined,
@@ -7647,14 +7729,36 @@ var Element = /*#__PURE__*/function (_Node) {
7647
7729
  _this.rBushNode = {
7648
7730
  aabb: undefined
7649
7731
  };
7732
+ /**
7733
+ * used with `getElementById()`
7734
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
7735
+ */
7650
7736
  _this.id = void 0;
7737
+ /**
7738
+ * used in `getElementsByName`
7739
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName
7740
+ */
7651
7741
  _this.name = void 0;
7742
+ /**
7743
+ * https://developer.mozilla.org/zh-CN/docs/Web/API/Element/namespaceURI
7744
+ */
7652
7745
  _this.namespaceURI = 'g';
7653
7746
  _this.scrollLeft = 0;
7654
7747
  _this.scrollTop = 0;
7748
+ /**
7749
+ * We don't support border now
7750
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
7751
+ */
7655
7752
  _this.clientTop = 0;
7656
7753
  _this.clientLeft = 0;
7754
+ /**
7755
+ * is destroyed or not
7756
+ */
7657
7757
  _this.destroyed = false;
7758
+ /**
7759
+ * compatible with `style`
7760
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
7761
+ */
7658
7762
  _this.style = {};
7659
7763
  _this.computedStyle = runtime.enableCSSParsing ? {
7660
7764
  anchor: unsetKeywordValue,
@@ -7683,6 +7787,9 @@ var Element = /*#__PURE__*/function (_Node) {
7683
7787
  filter: unsetKeywordValue,
7684
7788
  shadowType: unsetKeywordValue
7685
7789
  } : null;
7790
+ /**
7791
+ * Renderers will use these used values.
7792
+ */
7686
7793
  _this.parsedStyle = {
7687
7794
  // opacity: '',
7688
7795
  // fillOpacity: '',
@@ -7703,15 +7810,15 @@ var Element = /*#__PURE__*/function (_Node) {
7703
7810
  // textBaseline: '',
7704
7811
  // textTransform: '',
7705
7812
  };
7813
+ /**
7814
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
7815
+ */
7706
7816
  _this.attributes = {};
7707
7817
  return _this;
7708
7818
  }
7709
7819
  Element.isElement = function isElement(target) {
7710
7820
  return !!target.getAttribute;
7711
- }
7712
- /**
7713
- * Unique id.
7714
- */;
7821
+ };
7715
7822
  var _proto = Element.prototype;
7716
7823
  _proto.cloneNode = function cloneNode(deep) {
7717
7824
  throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);
@@ -7919,10 +8026,7 @@ var Element = /*#__PURE__*/function (_Node) {
7919
8026
  return this.parentNode.removeChild(this);
7920
8027
  }
7921
8028
  return this;
7922
- }
7923
- /**
7924
- * is destroyed or not
7925
- */;
8029
+ };
7926
8030
  _proto.destroy = function destroy() {
7927
8031
  // destroy itself before remove
7928
8032
  this.dispatchEvent(destroyEvent);
@@ -7963,21 +8067,14 @@ var Element = /*#__PURE__*/function (_Node) {
7963
8067
  */;
7964
8068
  _proto.getClientRects = function getClientRects() {
7965
8069
  return [this.getBoundingClientRect()];
7966
- }
7967
- /**
7968
- * compatible with `style`
7969
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
7970
- */;
8070
+ };
7971
8071
  /**
7972
8072
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/computedStyleMap
7973
8073
  * eg. circle.computedStyleMap().get('fill');
7974
8074
  */
7975
8075
  _proto.computedStyleMap = function computedStyleMap() {
7976
8076
  return new Map(Object.entries(this.computedStyle));
7977
- }
7978
- /**
7979
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
7980
- */;
8077
+ };
7981
8078
  /**
7982
8079
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
7983
8080
  */
@@ -8072,10 +8169,6 @@ var Element = /*#__PURE__*/function (_Node) {
8072
8169
  set: function set(className) {
8073
8170
  this.setAttribute('class', className);
8074
8171
  }
8075
- /**
8076
- * used in `getElementsByName`
8077
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName
8078
- */
8079
8172
  }, {
8080
8173
  key: "classList",
8081
8174
  get:
@@ -8147,17 +8240,40 @@ var FederatedMouseEvent = /*#__PURE__*/function (_FederatedEvent) {
8147
8240
  args[_key] = arguments[_key];
8148
8241
  }
8149
8242
  _this = _FederatedEvent.call.apply(_FederatedEvent, [this].concat(args)) || this;
8243
+ /** Whether the "alt" key was pressed when this mouse event occurred. */
8150
8244
  _this.altKey = void 0;
8245
+ /** The specific button that was pressed in this mouse event. */
8151
8246
  _this.button = void 0;
8247
+ /** The button depressed when this event occurred. */
8152
8248
  _this.buttons = void 0;
8249
+ /** Whether the "control" key was pressed when this mouse event occurred. */
8153
8250
  _this.ctrlKey = void 0;
8251
+ /** Whether the "meta" key was pressed when this mouse event occurred. */
8154
8252
  _this.metaKey = void 0;
8253
+ /** This is currently not implemented in the Federated Events API. */
8155
8254
  _this.relatedTarget = void 0;
8255
+ /** Whether the "shift" key was pressed when this mouse event occurred. */
8156
8256
  _this.shiftKey = void 0;
8257
+ /**
8258
+ * The coordinates of the mouse event relative to the canvas.
8259
+ */
8157
8260
  _this.client = new Point();
8261
+ /**
8262
+ * The movement in this pointer relative to the last `mousemove` event.
8263
+ */
8158
8264
  _this.movement = new Point();
8265
+ /**
8266
+ * The offset of the pointer coordinates w.r.t. target DisplayObject in world space. This is
8267
+ * not supported at the moment.
8268
+ */
8159
8269
  _this.offset = new Point();
8270
+ /**
8271
+ * The pointer coordinates in world space.
8272
+ */
8160
8273
  _this.global = new Point();
8274
+ /**
8275
+ * The pointer coordinates in sceen space.
8276
+ */
8161
8277
  _this.screen = new Point();
8162
8278
  return _this;
8163
8279
  }
@@ -8178,9 +8294,6 @@ var FederatedMouseEvent = /*#__PURE__*/function (_FederatedEvent) {
8178
8294
  get: function get() {
8179
8295
  return this.client.y;
8180
8296
  }
8181
- /**
8182
- * The movement in this pointer relative to the last `mousemove` event.
8183
- */
8184
8297
  }, {
8185
8298
  key: "movementX",
8186
8299
  get: function get() {
@@ -8191,10 +8304,6 @@ var FederatedMouseEvent = /*#__PURE__*/function (_FederatedEvent) {
8191
8304
  get: function get() {
8192
8305
  return this.movement.y;
8193
8306
  }
8194
- /**
8195
- * The offset of the pointer coordinates w.r.t. target DisplayObject in world space. This is
8196
- * not supported at the moment.
8197
- */
8198
8307
  }, {
8199
8308
  key: "offsetX",
8200
8309
  get: function get() {
@@ -8205,9 +8314,6 @@ var FederatedMouseEvent = /*#__PURE__*/function (_FederatedEvent) {
8205
8314
  get: function get() {
8206
8315
  return this.offset.y;
8207
8316
  }
8208
- /**
8209
- * The pointer coordinates in world space.
8210
- */
8211
8317
  }, {
8212
8318
  key: "globalX",
8213
8319
  get: function get() {
@@ -8218,9 +8324,6 @@ var FederatedMouseEvent = /*#__PURE__*/function (_FederatedEvent) {
8218
8324
  get: function get() {
8219
8325
  return this.global.y;
8220
8326
  }
8221
- /**
8222
- * The pointer coordinates in sceen space.
8223
- */
8224
8327
  }, {
8225
8328
  key: "screenX",
8226
8329
  get: function get() {
@@ -8243,15 +8346,69 @@ var FederatedPointerEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
8243
8346
  args[_key] = arguments[_key];
8244
8347
  }
8245
8348
  _this = _FederatedMouseEvent.call.apply(_FederatedMouseEvent, [this].concat(args)) || this;
8349
+ /**
8350
+ * The unique identifier of the pointer.
8351
+ *
8352
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId
8353
+ */
8246
8354
  _this.pointerId = void 0;
8355
+ /**
8356
+ * The width of the pointer's contact along the x-axis, measured in CSS pixels.
8357
+ * radiusX of TouchEvents will be represented by this value.
8358
+ *
8359
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
8360
+ */
8247
8361
  _this.width = 0;
8362
+ /**
8363
+ * The height of the pointer's contact along the y-axis, measured in CSS pixels.
8364
+ * radiusY of TouchEvents will be represented by this value.
8365
+ *
8366
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
8367
+ */
8248
8368
  _this.height = 0;
8369
+ /**
8370
+ * Indicates whether or not the pointer device that created the event is the primary pointer.
8371
+ *
8372
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
8373
+ */
8249
8374
  _this.isPrimary = false;
8375
+ /**
8376
+ * The type of pointer that triggered the event.
8377
+ *
8378
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
8379
+ */
8250
8380
  _this.pointerType = void 0;
8381
+ /**
8382
+ * Pressure applied by the pointing device during the event.
8383
+ *s
8384
+ * A Touch's force property will be represented by this value.
8385
+ *
8386
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure
8387
+ */
8251
8388
  _this.pressure = void 0;
8389
+ /**
8390
+ * Barrel pressure on a stylus pointer.
8391
+ *
8392
+ * @see https://w3c.github.io/pointerevents/#pointerevent-interface
8393
+ */
8252
8394
  _this.tangentialPressure = void 0;
8395
+ /**
8396
+ * The angle, in degrees, between the pointer device and the screen.
8397
+ *
8398
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX
8399
+ */
8253
8400
  _this.tiltX = void 0;
8401
+ /**
8402
+ * The angle, in degrees, between the pointer device and the screen.
8403
+ *
8404
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY
8405
+ */
8254
8406
  _this.tiltY = void 0;
8407
+ /**
8408
+ * Twist of a stylus pointer.
8409
+ *
8410
+ * @see https://w3c.github.io/pointerevents/#pointerevent-interface
8411
+ */
8255
8412
  _this.twist = void 0;
8256
8413
  return _this;
8257
8414
  }
@@ -8296,12 +8453,22 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
8296
8453
  args[_key] = arguments[_key];
8297
8454
  }
8298
8455
  _this = _FederatedMouseEvent.call.apply(_FederatedMouseEvent, [this].concat(args)) || this;
8456
+ /**
8457
+ * The units of `deltaX`, `deltaY`, and `deltaZ`. This is one of `DOM_DELTA_LINE`,
8458
+ * `DOM_DELTA_PAGE`, `DOM_DELTA_PIXEL`.
8459
+ */
8299
8460
  _this.deltaMode = void 0;
8461
+ /** Horizontal scroll amount */
8300
8462
  _this.deltaX = void 0;
8463
+ /** Vertical scroll amount */
8301
8464
  _this.deltaY = void 0;
8465
+ /** z-axis scroll amount. */
8302
8466
  _this.deltaZ = void 0;
8467
+ /** Units specified in lines. */
8303
8468
  _this.DOM_DELTA_LINE = 0;
8469
+ /** Units specified in pages. */
8304
8470
  _this.DOM_DELTA_PAGE = 1;
8471
+ /** Units specified in pixels. */
8305
8472
  _this.DOM_DELTA_PIXEL = 2;
8306
8473
  return _this;
8307
8474
  }
@@ -8417,6 +8584,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
8417
8584
  _this.isMutationObserved = false;
8418
8585
  _this.activeAnimations = [];
8419
8586
  _this.dataset = void 0;
8587
+ /**
8588
+ * Use `this.style.clipPath` instead.
8589
+ * @deprecated
8590
+ */
8420
8591
  _this.getClip = function () {
8421
8592
  return this.style.clipPath || null;
8422
8593
  };
@@ -9059,11 +9230,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
9059
9230
  */;
9060
9231
  _proto.setClip = function setClip(clipPath) {
9061
9232
  this.style.clipPath = clipPath;
9062
- }
9063
- /**
9064
- * Use `this.style.clipPath` instead.
9065
- * @deprecated
9066
- */;
9233
+ };
9067
9234
  /**
9068
9235
  * @deprecated
9069
9236
  */
@@ -11308,25 +11475,72 @@ var Camera = /*#__PURE__*/function () {
11308
11475
  function Camera() {
11309
11476
  this.canvas = void 0;
11310
11477
  this.eventEmitter = new EventEmitter__default['default']();
11478
+ /**
11479
+ * 相机矩阵
11480
+ */
11311
11481
  this.matrix = glMatrix.mat4.create();
11482
+ /**
11483
+ * u 轴
11484
+ * @see http://learnwebgl.brown37.net/07_cameras/camera_introduction.html#a-camera-definition
11485
+ */
11312
11486
  this.right = glMatrix.vec3.fromValues(1, 0, 0);
11487
+ /**
11488
+ * v 轴 +Y is down
11489
+ */
11313
11490
  this.up = glMatrix.vec3.fromValues(0, 1, 0);
11491
+ /**
11492
+ * n 轴 +Z is inside
11493
+ */
11314
11494
  this.forward = glMatrix.vec3.fromValues(0, 0, 1);
11495
+ /**
11496
+ * 相机位置
11497
+ */
11315
11498
  this.position = glMatrix.vec3.fromValues(0, 0, 1);
11499
+ /**
11500
+ * 视点位置
11501
+ */
11316
11502
  this.focalPoint = glMatrix.vec3.fromValues(0, 0, 0);
11503
+ /**
11504
+ * 视点到相机位置的向量
11505
+ * focalPoint - position
11506
+ */
11317
11507
  this.distanceVector = glMatrix.vec3.fromValues(0, 0, -1);
11508
+ /**
11509
+ * 相机位置到视点距离
11510
+ * length(focalPoint - position)
11511
+ */
11318
11512
  this.distance = 1;
11513
+ /**
11514
+ * @see https://en.wikipedia.org/wiki/Azimuth
11515
+ */
11319
11516
  this.azimuth = 0;
11320
11517
  this.elevation = 0;
11321
11518
  this.roll = 0;
11322
11519
  this.relAzimuth = 0;
11323
11520
  this.relElevation = 0;
11324
11521
  this.relRoll = 0;
11522
+ /**
11523
+ * 沿 n 轴移动时,保证移动速度从快到慢
11524
+ */
11325
11525
  this.dollyingStep = 0;
11326
11526
  this.maxDistance = Infinity;
11327
11527
  this.minDistance = -Infinity;
11528
+ /**
11529
+ * zoom factor of the camera, default is 1
11530
+ * eg. https://threejs.org/docs/#api/en/cameras/OrthographicCamera.zoom
11531
+ */
11328
11532
  this.zoom = 1;
11533
+ /**
11534
+ * invert the horizontal coordinate system HCS
11535
+ */
11329
11536
  this.rotateWorld = false;
11537
+ /**
11538
+ * 投影矩阵参数
11539
+ */
11540
+ /**
11541
+ * field of view [0-360]
11542
+ * @see http://en.wikipedia.org/wiki/Angle_of_view
11543
+ */
11330
11544
  this.fov = 30;
11331
11545
  this.near = 0.1;
11332
11546
  this.far = 1000;
@@ -11340,10 +11554,17 @@ var Camera = /*#__PURE__*/function () {
11340
11554
  this.jitteredProjectionMatrix = undefined;
11341
11555
  this.view = void 0;
11342
11556
  this.enableUpdate = true;
11557
+ // protected following = undefined;
11343
11558
  this.type = exports.CameraType.EXPLORING;
11344
11559
  this.trackingMode = exports.CameraTrackingMode.DEFAULT;
11345
11560
  this.projectionMode = exports.CameraProjectionMode.PERSPECTIVE;
11561
+ /**
11562
+ * for culling use
11563
+ */
11346
11564
  this.frustum = new Frustum();
11565
+ /**
11566
+ * ortho matrix for Canvas2D & SVG
11567
+ */
11347
11568
  this.orthoMatrix = glMatrix.mat4.create();
11348
11569
  }
11349
11570
  var _proto = Camera.prototype;
@@ -12164,410 +12385,271 @@ var EventService = /*#__PURE__*/function () {
12164
12385
  this.pickHandler = void 0;
12165
12386
  this.tmpMatrix = glMatrix.mat4.create();
12166
12387
  this.tmpVec3 = glMatrix.vec3.create();
12167
- this.onPointerDown = /*#__PURE__*/function () {
12168
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(from) {
12169
- var e, isRightButton, trackingData;
12170
- return _regeneratorRuntime().wrap(function _callee$(_context) {
12171
- while (1) {
12172
- switch (_context.prev = _context.next) {
12173
- case 0:
12174
- _context.next = 2;
12175
- return _this.createPointerEvent(from);
12176
- case 2:
12177
- e = _context.sent;
12178
- _this.dispatchEvent(e, 'pointerdown');
12179
- if (e.pointerType === 'touch') {
12180
- _this.dispatchEvent(e, 'touchstart');
12181
- } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12182
- isRightButton = e.button === 2;
12183
- _this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
12184
- }
12185
- trackingData = _this.trackingData(from.pointerId);
12186
- trackingData.pressTargetsByButton[from.button] = e.composedPath();
12187
- _this.freeEvent(e);
12188
- case 8:
12189
- case "end":
12190
- return _context.stop();
12191
- }
12388
+ this.onPointerDown = function (from) {
12389
+ // if (!(from instanceof FederatedPointerEvent)) {
12390
+ // return;
12391
+ // }
12392
+ var e = _this.createPointerEvent(from);
12393
+ _this.dispatchEvent(e, 'pointerdown');
12394
+ if (e.pointerType === 'touch') {
12395
+ _this.dispatchEvent(e, 'touchstart');
12396
+ } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12397
+ var isRightButton = e.button === 2;
12398
+ _this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
12399
+ }
12400
+ var trackingData = _this.trackingData(from.pointerId);
12401
+ trackingData.pressTargetsByButton[from.button] = e.composedPath();
12402
+ _this.freeEvent(e);
12403
+ };
12404
+ this.onPointerUp = function (from) {
12405
+ // if (!(from instanceof FederatedPointerEvent)) {
12406
+ // return;
12407
+ // }
12408
+ var now = performance.now();
12409
+ var e = _this.createPointerEvent(from);
12410
+ _this.dispatchEvent(e, 'pointerup');
12411
+ if (e.pointerType === 'touch') {
12412
+ _this.dispatchEvent(e, 'touchend');
12413
+ } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12414
+ var isRightButton = e.button === 2;
12415
+ _this.dispatchEvent(e, isRightButton ? 'rightup' : 'mouseup');
12416
+ }
12417
+ var trackingData = _this.trackingData(from.pointerId);
12418
+ var pressTarget = _this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
12419
+ var clickTarget = pressTarget;
12420
+ // pointerupoutside only bubbles. It only bubbles upto the parent that doesn't contain
12421
+ // the pointerup location.
12422
+ if (pressTarget && !e.composedPath().includes(pressTarget)) {
12423
+ var currentTarget = pressTarget;
12424
+ while (currentTarget && !e.composedPath().includes(currentTarget)) {
12425
+ e.currentTarget = currentTarget;
12426
+ _this.notifyTarget(e, 'pointerupoutside');
12427
+ if (e.pointerType === 'touch') {
12428
+ _this.notifyTarget(e, 'touchendoutside');
12429
+ } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12430
+ var _isRightButton = e.button === 2;
12431
+ _this.notifyTarget(e, _isRightButton ? 'rightupoutside' : 'mouseupoutside');
12192
12432
  }
12193
- }, _callee);
12194
- }));
12195
- return function (_x) {
12196
- return _ref.apply(this, arguments);
12197
- };
12198
- }();
12199
- this.onPointerUp = /*#__PURE__*/function () {
12200
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(from) {
12201
- var now, e, isRightButton, trackingData, pressTarget, clickTarget, currentTarget, _isRightButton, _e$detail, clickEvent, clickHistory;
12202
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12203
- while (1) {
12204
- switch (_context2.prev = _context2.next) {
12205
- case 0:
12206
- // if (!(from instanceof FederatedPointerEvent)) {
12207
- // return;
12208
- // }
12209
- now = performance.now();
12210
- _context2.next = 3;
12211
- return _this.createPointerEvent(from);
12212
- case 3:
12213
- e = _context2.sent;
12214
- _this.dispatchEvent(e, 'pointerup');
12215
- if (e.pointerType === 'touch') {
12216
- _this.dispatchEvent(e, 'touchend');
12217
- } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12218
- isRightButton = e.button === 2;
12219
- _this.dispatchEvent(e, isRightButton ? 'rightup' : 'mouseup');
12220
- }
12221
- trackingData = _this.trackingData(from.pointerId);
12222
- pressTarget = _this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
12223
- clickTarget = pressTarget; // pointerupoutside only bubbles. It only bubbles upto the parent that doesn't contain
12224
- // the pointerup location.
12225
- if (pressTarget && !e.composedPath().includes(pressTarget)) {
12226
- currentTarget = pressTarget;
12227
- while (currentTarget && !e.composedPath().includes(currentTarget)) {
12228
- e.currentTarget = currentTarget;
12229
- _this.notifyTarget(e, 'pointerupoutside');
12230
- if (e.pointerType === 'touch') {
12231
- _this.notifyTarget(e, 'touchendoutside');
12232
- } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12233
- _isRightButton = e.button === 2;
12234
- _this.notifyTarget(e, _isRightButton ? 'rightupoutside' : 'mouseupoutside');
12235
- }
12236
- if (Node.isNode(currentTarget)) {
12237
- currentTarget = currentTarget.parentNode;
12238
- }
12239
- }
12240
- delete trackingData.pressTargetsByButton[from.button];
12241
- // currentTarget is the most specific ancestor holding both the pointerdown and pointerup
12242
- // targets. That is - it's our click target!
12243
- clickTarget = currentTarget;
12244
- }
12245
- if (clickTarget) {
12246
- clickEvent = _this.clonePointerEvent(e, 'click');
12247
- clickEvent.target = clickTarget;
12248
- clickEvent.path = [];
12249
- if (!trackingData.clicksByButton[from.button]) {
12250
- trackingData.clicksByButton[from.button] = {
12251
- clickCount: 0,
12252
- target: clickEvent.target,
12253
- timeStamp: now
12254
- };
12255
- }
12256
- clickHistory = trackingData.clicksByButton[from.button];
12257
- if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
12258
- ++clickHistory.clickCount;
12259
- } else {
12260
- clickHistory.clickCount = 1;
12261
- }
12262
- clickHistory.target = clickEvent.target;
12263
- clickHistory.timeStamp = now;
12264
- clickEvent.detail = clickHistory.clickCount;
12265
- // @see https://github.com/antvis/G/issues/1091
12266
- if (!((_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.preventClick)) {
12267
- if (clickEvent.pointerType === 'mouse' || clickEvent.pointerType === 'touch') {
12268
- _this.dispatchEvent(clickEvent, 'click');
12269
- }
12270
- _this.dispatchEvent(clickEvent, 'pointertap');
12271
- }
12272
- _this.freeEvent(clickEvent);
12273
- }
12274
- _this.freeEvent(e);
12275
- case 12:
12276
- case "end":
12277
- return _context2.stop();
12278
- }
12433
+ if (Node.isNode(currentTarget)) {
12434
+ currentTarget = currentTarget.parentNode;
12279
12435
  }
12280
- }, _callee2);
12281
- }));
12282
- return function (_x2) {
12283
- return _ref2.apply(this, arguments);
12284
- };
12285
- }();
12286
- this.onPointerMove = /*#__PURE__*/function () {
12287
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(from) {
12288
- var e, isMouse, trackingData, outTarget, outType, outEvent, leaveEvent, overType, overEvent, overTargetAncestor, didPointerEnter, enterEvent;
12289
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
12290
- while (1) {
12291
- switch (_context3.prev = _context3.next) {
12292
- case 0:
12293
- _context3.next = 2;
12294
- return _this.createPointerEvent(from);
12295
- case 2:
12296
- e = _context3.sent;
12297
- isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
12298
- trackingData = _this.trackingData(from.pointerId);
12299
- outTarget = _this.findMountedTarget(trackingData.overTargets); // First pointerout/pointerleave
12300
- if (!(trackingData.overTargets && outTarget !== e.target)) {
12301
- _context3.next = 21;
12302
- break;
12303
- }
12304
- // pointerout always occurs on the overTarget when the pointer hovers over another element.
12305
- outType = from.type === 'mousemove' ? 'mouseout' : 'pointerout';
12306
- _context3.next = 10;
12307
- return _this.createPointerEvent(from, outType, outTarget || undefined);
12308
- case 10:
12309
- outEvent = _context3.sent;
12310
- _this.dispatchEvent(outEvent, 'pointerout');
12311
- if (isMouse) _this.dispatchEvent(outEvent, 'mouseout');
12312
- // If the pointer exits overTarget and its descendants, then a pointerleave event is also fired. This event
12313
- // is dispatched to all ancestors that no longer capture the pointer.
12314
- if (e.composedPath().includes(outTarget)) {
12315
- _context3.next = 20;
12316
- break;
12317
- }
12318
- _context3.next = 16;
12319
- return _this.createPointerEvent(from, 'pointerleave', outTarget || undefined);
12320
- case 16:
12321
- leaveEvent = _context3.sent;
12322
- leaveEvent.eventPhase = leaveEvent.AT_TARGET;
12323
- while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
12324
- leaveEvent.currentTarget = leaveEvent.target;
12325
- _this.notifyTarget(leaveEvent);
12326
- if (isMouse) {
12327
- _this.notifyTarget(leaveEvent, 'mouseleave');
12328
- }
12329
- if (Node.isNode(leaveEvent.target)) {
12330
- leaveEvent.target = leaveEvent.target.parentNode;
12331
- }
12332
- }
12333
- _this.freeEvent(leaveEvent);
12334
- case 20:
12335
- _this.freeEvent(outEvent);
12336
- case 21:
12337
- if (!(outTarget !== e.target)) {
12338
- _context3.next = 36;
12339
- break;
12340
- }
12341
- // pointerover always occurs on the new overTarget
12342
- overType = from.type === 'mousemove' ? 'mouseover' : 'pointerover';
12343
- overEvent = _this.clonePointerEvent(e, overType); // clone faster
12344
- _this.dispatchEvent(overEvent, 'pointerover');
12345
- if (isMouse) _this.dispatchEvent(overEvent, 'mouseover');
12346
- // Probe whether the newly hovered Node is an ancestor of the original overTarget.
12347
- overTargetAncestor = outTarget && Node.isNode(outTarget) && outTarget.parentNode;
12348
- case 27:
12349
- if (!(overTargetAncestor && overTargetAncestor !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode))) {
12350
- _context3.next = 33;
12351
- break;
12352
- }
12353
- if (!(overTargetAncestor === e.target)) {
12354
- _context3.next = 30;
12355
- break;
12356
- }
12357
- return _context3.abrupt("break", 33);
12358
- case 30:
12359
- overTargetAncestor = overTargetAncestor.parentNode;
12360
- _context3.next = 27;
12361
- break;
12362
- case 33:
12363
- // The pointer has entered a non-ancestor of the original overTarget. This means we need a pointerentered
12364
- // event.
12365
- didPointerEnter = !overTargetAncestor || overTargetAncestor === (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode);
12366
- if (didPointerEnter) {
12367
- enterEvent = _this.clonePointerEvent(e, 'pointerenter');
12368
- enterEvent.eventPhase = enterEvent.AT_TARGET;
12369
- while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12370
- enterEvent.currentTarget = enterEvent.target;
12371
- _this.notifyTarget(enterEvent);
12372
- if (isMouse) _this.notifyTarget(enterEvent, 'mouseenter');
12373
- if (Node.isNode(enterEvent.target)) {
12374
- enterEvent.target = enterEvent.target.parentNode;
12375
- }
12376
- }
12377
- _this.freeEvent(enterEvent);
12378
- }
12379
- _this.freeEvent(overEvent);
12380
- case 36:
12381
- // Then pointermove
12382
- _this.dispatchEvent(e, 'pointermove');
12383
- if (e.pointerType === 'touch') _this.dispatchEvent(e, 'touchmove');
12384
- if (isMouse) {
12385
- _this.dispatchEvent(e, 'mousemove');
12386
- _this.cursor = _this.getCursor(e.target);
12387
- }
12388
- trackingData.overTargets = e.composedPath();
12389
- _this.freeEvent(e);
12390
- case 41:
12391
- case "end":
12392
- return _context3.stop();
12393
- }
12436
+ }
12437
+ delete trackingData.pressTargetsByButton[from.button];
12438
+ // currentTarget is the most specific ancestor holding both the pointerdown and pointerup
12439
+ // targets. That is - it's our click target!
12440
+ clickTarget = currentTarget;
12441
+ }
12442
+ if (clickTarget) {
12443
+ var _e$detail;
12444
+ var clickEvent = _this.clonePointerEvent(e, 'click');
12445
+ clickEvent.target = clickTarget;
12446
+ clickEvent.path = [];
12447
+ if (!trackingData.clicksByButton[from.button]) {
12448
+ trackingData.clicksByButton[from.button] = {
12449
+ clickCount: 0,
12450
+ target: clickEvent.target,
12451
+ timeStamp: now
12452
+ };
12453
+ }
12454
+ var clickHistory = trackingData.clicksByButton[from.button];
12455
+ if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
12456
+ ++clickHistory.clickCount;
12457
+ } else {
12458
+ clickHistory.clickCount = 1;
12459
+ }
12460
+ clickHistory.target = clickEvent.target;
12461
+ clickHistory.timeStamp = now;
12462
+ clickEvent.detail = clickHistory.clickCount;
12463
+ // @see https://github.com/antvis/G/issues/1091
12464
+ if (!((_e$detail = e.detail) === null || _e$detail === void 0 ? void 0 : _e$detail.preventClick)) {
12465
+ if (!_this.context.config.useNativeClickEvent && (clickEvent.pointerType === 'mouse' || clickEvent.pointerType === 'touch')) {
12466
+ _this.dispatchEvent(clickEvent, 'click');
12394
12467
  }
12395
- }, _callee3);
12396
- }));
12397
- return function (_x3) {
12398
- return _ref3.apply(this, arguments);
12399
- };
12400
- }();
12401
- this.onPointerOut = /*#__PURE__*/function () {
12402
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(from) {
12403
- var trackingData, isMouse, outTarget, outEvent, leaveEvent;
12404
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
12405
- while (1) {
12406
- switch (_context4.prev = _context4.next) {
12407
- case 0:
12408
- // if (!(from instanceof FederatedPointerEvent)) {
12409
- // return;
12410
- // }
12411
- trackingData = _this.trackingData(from.pointerId);
12412
- if (!trackingData.overTargets) {
12413
- _context4.next = 17;
12414
- break;
12415
- }
12416
- isMouse = from.pointerType === 'mouse' || from.pointerType === 'pen';
12417
- outTarget = _this.findMountedTarget(trackingData.overTargets); // pointerout first
12418
- _context4.next = 6;
12419
- return _this.createPointerEvent(from, 'pointerout', outTarget || undefined);
12420
- case 6:
12421
- outEvent = _context4.sent;
12422
- _this.dispatchEvent(outEvent);
12423
- if (isMouse) _this.dispatchEvent(outEvent, 'mouseout');
12424
- // pointerleave(s) are also dispatched b/c the pointer must've left rootTarget and its descendants to
12425
- // get an upstream pointerout event (upstream events do not know rootTarget has descendants).
12426
- _context4.next = 11;
12427
- return _this.createPointerEvent(from, 'pointerleave', outTarget || undefined);
12428
- case 11:
12429
- leaveEvent = _context4.sent;
12430
- leaveEvent.eventPhase = leaveEvent.AT_TARGET;
12431
- while (leaveEvent.target && leaveEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12432
- leaveEvent.currentTarget = leaveEvent.target;
12433
- _this.notifyTarget(leaveEvent);
12434
- if (isMouse) {
12435
- _this.notifyTarget(leaveEvent, 'mouseleave');
12436
- }
12437
- if (Node.isNode(leaveEvent.target)) {
12438
- leaveEvent.target = leaveEvent.target.parentNode;
12439
- }
12440
- }
12441
- trackingData.overTargets = null;
12442
- _this.freeEvent(outEvent);
12443
- _this.freeEvent(leaveEvent);
12444
- case 17:
12445
- _this.cursor = null;
12446
- case 18:
12447
- case "end":
12448
- return _context4.stop();
12468
+ _this.dispatchEvent(clickEvent, 'pointertap');
12469
+ }
12470
+ _this.freeEvent(clickEvent);
12471
+ }
12472
+ _this.freeEvent(e);
12473
+ };
12474
+ this.onPointerMove = function (from) {
12475
+ // if (!(from instanceof FederatedPointerEvent)) {
12476
+ // return;
12477
+ // }
12478
+ var e = _this.createPointerEvent(from);
12479
+ var isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
12480
+ var trackingData = _this.trackingData(from.pointerId);
12481
+ var outTarget = _this.findMountedTarget(trackingData.overTargets);
12482
+ // First pointerout/pointerleave
12483
+ if (trackingData.overTargets && outTarget !== e.target) {
12484
+ // pointerout always occurs on the overTarget when the pointer hovers over another element.
12485
+ var outType = from.type === 'mousemove' ? 'mouseout' : 'pointerout';
12486
+ var outEvent = _this.createPointerEvent(from, outType, outTarget || undefined);
12487
+ _this.dispatchEvent(outEvent, 'pointerout');
12488
+ if (isMouse) _this.dispatchEvent(outEvent, 'mouseout');
12489
+ // If the pointer exits overTarget and its descendants, then a pointerleave event is also fired. This event
12490
+ // is dispatched to all ancestors that no longer capture the pointer.
12491
+ if (!e.composedPath().includes(outTarget)) {
12492
+ var leaveEvent = _this.createPointerEvent(from, 'pointerleave', outTarget || undefined);
12493
+ leaveEvent.eventPhase = leaveEvent.AT_TARGET;
12494
+ while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
12495
+ leaveEvent.currentTarget = leaveEvent.target;
12496
+ _this.notifyTarget(leaveEvent);
12497
+ if (isMouse) {
12498
+ _this.notifyTarget(leaveEvent, 'mouseleave');
12449
12499
  }
12450
- }
12451
- }, _callee4);
12452
- }));
12453
- return function (_x4) {
12454
- return _ref4.apply(this, arguments);
12455
- };
12456
- }();
12457
- this.onPointerOver = /*#__PURE__*/function () {
12458
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(from) {
12459
- var trackingData, e, isMouse, enterEvent;
12460
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
12461
- while (1) {
12462
- switch (_context5.prev = _context5.next) {
12463
- case 0:
12464
- // if (!(from instanceof FederatedPointerEvent)) {
12465
- // return;
12466
- // }
12467
- trackingData = _this.trackingData(from.pointerId);
12468
- _context5.next = 3;
12469
- return _this.createPointerEvent(from);
12470
- case 3:
12471
- e = _context5.sent;
12472
- isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
12473
- _this.dispatchEvent(e, 'pointerover');
12474
- if (isMouse) _this.dispatchEvent(e, 'mouseover');
12475
- if (e.pointerType === 'mouse') _this.cursor = _this.getCursor(e.target);
12476
- // pointerenter events must be fired since the pointer entered from upstream.
12477
- enterEvent = _this.clonePointerEvent(e, 'pointerenter');
12478
- enterEvent.eventPhase = enterEvent.AT_TARGET;
12479
- while (enterEvent.target && enterEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12480
- enterEvent.currentTarget = enterEvent.target;
12481
- _this.notifyTarget(enterEvent);
12482
- if (isMouse) {
12483
- // mouseenter should not bubble
12484
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event#usage_notes
12485
- _this.notifyTarget(enterEvent, 'mouseenter');
12486
- }
12487
- if (Node.isNode(enterEvent.target)) {
12488
- enterEvent.target = enterEvent.target.parentNode;
12489
- }
12490
- }
12491
- trackingData.overTargets = e.composedPath();
12492
- _this.freeEvent(e);
12493
- _this.freeEvent(enterEvent);
12494
- case 14:
12495
- case "end":
12496
- return _context5.stop();
12500
+ if (Node.isNode(leaveEvent.target)) {
12501
+ leaveEvent.target = leaveEvent.target.parentNode;
12497
12502
  }
12498
12503
  }
12499
- }, _callee5);
12500
- }));
12501
- return function (_x5) {
12502
- return _ref5.apply(this, arguments);
12503
- };
12504
- }();
12505
- this.onPointerUpOutside = /*#__PURE__*/function () {
12506
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(from) {
12507
- var trackingData, pressTarget, e, currentTarget;
12508
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
12509
- while (1) {
12510
- switch (_context6.prev = _context6.next) {
12511
- case 0:
12512
- // if (!(from instanceof FederatedPointerEvent)) {
12513
- // return;
12514
- // }
12515
- trackingData = _this.trackingData(from.pointerId);
12516
- pressTarget = _this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
12517
- _context6.next = 4;
12518
- return _this.createPointerEvent(from);
12519
- case 4:
12520
- e = _context6.sent;
12521
- if (pressTarget) {
12522
- currentTarget = pressTarget;
12523
- while (currentTarget) {
12524
- e.currentTarget = currentTarget;
12525
- _this.notifyTarget(e, 'pointerupoutside');
12526
- if (e.pointerType === 'touch') ; else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12527
- _this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
12528
- }
12529
- if (Node.isNode(currentTarget)) {
12530
- currentTarget = currentTarget.parentNode;
12531
- }
12532
- }
12533
- delete trackingData.pressTargetsByButton[from.button];
12534
- }
12535
- _this.freeEvent(e);
12536
- case 7:
12537
- case "end":
12538
- return _context6.stop();
12504
+ _this.freeEvent(leaveEvent);
12505
+ }
12506
+ _this.freeEvent(outEvent);
12507
+ }
12508
+ // Then pointerover
12509
+ if (outTarget !== e.target) {
12510
+ // pointerover always occurs on the new overTarget
12511
+ var overType = from.type === 'mousemove' ? 'mouseover' : 'pointerover';
12512
+ var overEvent = _this.clonePointerEvent(e, overType); // clone faster
12513
+ _this.dispatchEvent(overEvent, 'pointerover');
12514
+ if (isMouse) _this.dispatchEvent(overEvent, 'mouseover');
12515
+ // Probe whether the newly hovered Node is an ancestor of the original overTarget.
12516
+ var overTargetAncestor = outTarget && Node.isNode(outTarget) && outTarget.parentNode;
12517
+ while (overTargetAncestor && overTargetAncestor !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12518
+ if (overTargetAncestor === e.target) break;
12519
+ overTargetAncestor = overTargetAncestor.parentNode;
12520
+ }
12521
+ // The pointer has entered a non-ancestor of the original overTarget. This means we need a pointerentered
12522
+ // event.
12523
+ var didPointerEnter = !overTargetAncestor || overTargetAncestor === (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode);
12524
+ if (didPointerEnter) {
12525
+ var enterEvent = _this.clonePointerEvent(e, 'pointerenter');
12526
+ enterEvent.eventPhase = enterEvent.AT_TARGET;
12527
+ while (enterEvent.target && enterEvent.target !== outTarget && enterEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12528
+ enterEvent.currentTarget = enterEvent.target;
12529
+ _this.notifyTarget(enterEvent);
12530
+ if (isMouse) _this.notifyTarget(enterEvent, 'mouseenter');
12531
+ if (Node.isNode(enterEvent.target)) {
12532
+ enterEvent.target = enterEvent.target.parentNode;
12539
12533
  }
12540
12534
  }
12541
- }, _callee6);
12542
- }));
12543
- return function (_x6) {
12544
- return _ref6.apply(this, arguments);
12545
- };
12546
- }();
12547
- this.onWheel = /*#__PURE__*/function () {
12548
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(from) {
12549
- var wheelEvent;
12550
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
12551
- while (1) {
12552
- switch (_context7.prev = _context7.next) {
12553
- case 0:
12554
- _context7.next = 2;
12555
- return _this.createWheelEvent(from);
12556
- case 2:
12557
- wheelEvent = _context7.sent;
12558
- _this.dispatchEvent(wheelEvent);
12559
- _this.freeEvent(wheelEvent);
12560
- case 5:
12561
- case "end":
12562
- return _context7.stop();
12563
- }
12535
+ _this.freeEvent(enterEvent);
12536
+ }
12537
+ _this.freeEvent(overEvent);
12538
+ }
12539
+ // Then pointermove
12540
+ _this.dispatchEvent(e, 'pointermove');
12541
+ if (e.pointerType === 'touch') _this.dispatchEvent(e, 'touchmove');
12542
+ if (isMouse) {
12543
+ _this.dispatchEvent(e, 'mousemove');
12544
+ _this.cursor = _this.getCursor(e.target);
12545
+ }
12546
+ trackingData.overTargets = e.composedPath();
12547
+ _this.freeEvent(e);
12548
+ };
12549
+ this.onPointerOut = function (from) {
12550
+ // if (!(from instanceof FederatedPointerEvent)) {
12551
+ // return;
12552
+ // }
12553
+ var trackingData = _this.trackingData(from.pointerId);
12554
+ if (trackingData.overTargets) {
12555
+ var isMouse = from.pointerType === 'mouse' || from.pointerType === 'pen';
12556
+ var outTarget = _this.findMountedTarget(trackingData.overTargets);
12557
+ // pointerout first
12558
+ var outEvent = _this.createPointerEvent(from, 'pointerout', outTarget || undefined);
12559
+ _this.dispatchEvent(outEvent);
12560
+ if (isMouse) _this.dispatchEvent(outEvent, 'mouseout');
12561
+ // pointerleave(s) are also dispatched b/c the pointer must've left rootTarget and its descendants to
12562
+ // get an upstream pointerout event (upstream events do not know rootTarget has descendants).
12563
+ var leaveEvent = _this.createPointerEvent(from, 'pointerleave', outTarget || undefined);
12564
+ leaveEvent.eventPhase = leaveEvent.AT_TARGET;
12565
+ while (leaveEvent.target && leaveEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12566
+ leaveEvent.currentTarget = leaveEvent.target;
12567
+ _this.notifyTarget(leaveEvent);
12568
+ if (isMouse) {
12569
+ _this.notifyTarget(leaveEvent, 'mouseleave');
12564
12570
  }
12565
- }, _callee7);
12566
- }));
12567
- return function (_x7) {
12568
- return _ref7.apply(this, arguments);
12569
- };
12570
- }();
12571
+ if (Node.isNode(leaveEvent.target)) {
12572
+ leaveEvent.target = leaveEvent.target.parentNode;
12573
+ }
12574
+ }
12575
+ trackingData.overTargets = null;
12576
+ _this.freeEvent(outEvent);
12577
+ _this.freeEvent(leaveEvent);
12578
+ }
12579
+ _this.cursor = null;
12580
+ };
12581
+ this.onPointerOver = function (from) {
12582
+ // if (!(from instanceof FederatedPointerEvent)) {
12583
+ // return;
12584
+ // }
12585
+ var trackingData = _this.trackingData(from.pointerId);
12586
+ var e = _this.createPointerEvent(from);
12587
+ var isMouse = e.pointerType === 'mouse' || e.pointerType === 'pen';
12588
+ _this.dispatchEvent(e, 'pointerover');
12589
+ if (isMouse) _this.dispatchEvent(e, 'mouseover');
12590
+ if (e.pointerType === 'mouse') _this.cursor = _this.getCursor(e.target);
12591
+ // pointerenter events must be fired since the pointer entered from upstream.
12592
+ var enterEvent = _this.clonePointerEvent(e, 'pointerenter');
12593
+ enterEvent.eventPhase = enterEvent.AT_TARGET;
12594
+ while (enterEvent.target && enterEvent.target !== (Node.isNode(_this.rootTarget) && _this.rootTarget.parentNode)) {
12595
+ enterEvent.currentTarget = enterEvent.target;
12596
+ _this.notifyTarget(enterEvent);
12597
+ if (isMouse) {
12598
+ // mouseenter should not bubble
12599
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event#usage_notes
12600
+ _this.notifyTarget(enterEvent, 'mouseenter');
12601
+ }
12602
+ if (Node.isNode(enterEvent.target)) {
12603
+ enterEvent.target = enterEvent.target.parentNode;
12604
+ }
12605
+ }
12606
+ trackingData.overTargets = e.composedPath();
12607
+ _this.freeEvent(e);
12608
+ _this.freeEvent(enterEvent);
12609
+ };
12610
+ this.onPointerUpOutside = function (from) {
12611
+ // if (!(from instanceof FederatedPointerEvent)) {
12612
+ // return;
12613
+ // }
12614
+ var trackingData = _this.trackingData(from.pointerId);
12615
+ var pressTarget = _this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);
12616
+ var e = _this.createPointerEvent(from);
12617
+ if (pressTarget) {
12618
+ var currentTarget = pressTarget;
12619
+ while (currentTarget) {
12620
+ e.currentTarget = currentTarget;
12621
+ _this.notifyTarget(e, 'pointerupoutside');
12622
+ if (e.pointerType === 'touch') ; else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
12623
+ _this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
12624
+ }
12625
+ if (Node.isNode(currentTarget)) {
12626
+ currentTarget = currentTarget.parentNode;
12627
+ }
12628
+ }
12629
+ delete trackingData.pressTargetsByButton[from.button];
12630
+ }
12631
+ _this.freeEvent(e);
12632
+ };
12633
+ this.onWheel = function (from) {
12634
+ // if (!(from instanceof FederatedWheelEvent)) {
12635
+ // return;
12636
+ // }
12637
+ var wheelEvent = _this.createWheelEvent(from);
12638
+ _this.dispatchEvent(wheelEvent);
12639
+ _this.freeEvent(wheelEvent);
12640
+ };
12641
+ this.onClick = function (from) {
12642
+ if (_this.context.config.useNativeClickEvent) {
12643
+ var e = _this.createPointerEvent(from);
12644
+ _this.dispatchEvent(e);
12645
+ _this.freeEvent(e);
12646
+ }
12647
+ };
12648
+ this.onPointerCancel = function (from) {
12649
+ var e = _this.createPointerEvent(from);
12650
+ _this.dispatchEvent(e);
12651
+ _this.freeEvent(e);
12652
+ };
12571
12653
  this.globalRuntime = globalRuntime;
12572
12654
  this.context = context;
12573
12655
  }
@@ -12579,9 +12661,11 @@ var EventService = /*#__PURE__*/function () {
12579
12661
  this.addEventMapping('pointermove', this.onPointerMove);
12580
12662
  this.addEventMapping('pointerout', this.onPointerOut);
12581
12663
  this.addEventMapping('pointerleave', this.onPointerOut);
12664
+ this.addEventMapping('pointercancel', this.onPointerCancel);
12582
12665
  this.addEventMapping('pointerover', this.onPointerOver);
12583
12666
  this.addEventMapping('pointerupoutside', this.onPointerUpOutside);
12584
12667
  this.addEventMapping('wheel', this.onWheel);
12668
+ this.addEventMapping('click', this.onClick);
12585
12669
  };
12586
12670
  _proto.destroy = function destroy() {
12587
12671
  this.emitter.removeAllListeners();
@@ -12597,9 +12681,9 @@ var EventService = /*#__PURE__*/function () {
12597
12681
  var bbox = this.context.contextService.getBoundingClientRect();
12598
12682
  return new Point(canvas.x + ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0), canvas.y + ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0));
12599
12683
  };
12600
- _proto.viewport2Canvas = function viewport2Canvas(_ref8) {
12601
- var x = _ref8.x,
12602
- y = _ref8.y;
12684
+ _proto.viewport2Canvas = function viewport2Canvas(_ref) {
12685
+ var x = _ref.x,
12686
+ y = _ref.y;
12603
12687
  var canvas = this.rootTarget.defaultView;
12604
12688
  var camera = canvas.getCamera();
12605
12689
  var _this$context$config = this.context.config,
@@ -12722,58 +12806,24 @@ var EventService = /*#__PURE__*/function () {
12722
12806
  }
12723
12807
  return propagationPath;
12724
12808
  };
12725
- _proto.hitTest = /*#__PURE__*/function () {
12726
- var _hitTest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(position) {
12727
- var viewportX, viewportY, _this$context$config3, width, height;
12728
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
12729
- while (1) {
12730
- switch (_context8.prev = _context8.next) {
12731
- case 0:
12732
- viewportX = position.viewportX, viewportY = position.viewportY;
12733
- _this$context$config3 = this.context.config, width = _this$context$config3.width, height = _this$context$config3.height; // outside canvas
12734
- if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
12735
- _context8.next = 4;
12736
- break;
12737
- }
12738
- return _context8.abrupt("return", null);
12739
- case 4:
12740
- _context8.next = 6;
12741
- return this.pickHandler(position);
12742
- case 6:
12743
- _context8.t1 = _context8.sent;
12744
- if (_context8.t1) {
12745
- _context8.next = 9;
12746
- break;
12747
- }
12748
- _context8.t1 = this.rootTarget;
12749
- case 9:
12750
- _context8.t0 = _context8.t1;
12751
- if (_context8.t0) {
12752
- _context8.next = 12;
12753
- break;
12754
- }
12755
- _context8.t0 =
12756
- // return Document
12757
- null;
12758
- case 12:
12759
- return _context8.abrupt("return", _context8.t0);
12760
- case 13:
12761
- case "end":
12762
- return _context8.stop();
12763
- }
12764
- }
12765
- }, _callee8, this);
12766
- }));
12767
- function hitTest(_x8) {
12768
- return _hitTest.apply(this, arguments);
12809
+ _proto.hitTest = function hitTest(position) {
12810
+ var viewportX = position.viewportX,
12811
+ viewportY = position.viewportY;
12812
+ var _this$context$config3 = this.context.config,
12813
+ width = _this$context$config3.width,
12814
+ height = _this$context$config3.height;
12815
+ // outside canvas
12816
+ if (viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height) {
12817
+ return null;
12769
12818
  }
12770
- return hitTest;
12771
- }()
12819
+ return this.pickHandler(position) || this.rootTarget ||
12820
+ // return Document
12821
+ null;
12822
+ }
12772
12823
  /**
12773
12824
  * whether the native event trigger came from Canvas,
12774
12825
  * should account for HTML shape
12775
- */
12776
- ;
12826
+ */;
12777
12827
  _proto.isNativeEventFromCanvas = function isNativeEventFromCanvas(event) {
12778
12828
  var _event$nativeEvent;
12779
12829
  var $el = this.context.contextService.getDomElement();
@@ -12806,135 +12856,41 @@ var EventService = /*#__PURE__*/function () {
12806
12856
  }
12807
12857
  return null;
12808
12858
  };
12809
- _proto.pickTarget = /*#__PURE__*/function () {
12810
- var _pickTarget = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(event) {
12811
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
12812
- while (1) {
12813
- switch (_context9.prev = _context9.next) {
12814
- case 0:
12815
- return _context9.abrupt("return", this.hitTest({
12816
- clientX: event.clientX,
12817
- clientY: event.clientY,
12818
- viewportX: event.viewportX,
12819
- viewportY: event.viewportY,
12820
- x: event.canvasX,
12821
- y: event.canvasY
12822
- }));
12823
- case 1:
12824
- case "end":
12825
- return _context9.stop();
12826
- }
12827
- }
12828
- }, _callee9, this);
12829
- }));
12830
- function pickTarget(_x9) {
12831
- return _pickTarget.apply(this, arguments);
12832
- }
12833
- return pickTarget;
12834
- }();
12835
- _proto.createPointerEvent = /*#__PURE__*/function () {
12836
- var _createPointerEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(from, type, target) {
12837
- var event, existedHTML;
12838
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
12839
- while (1) {
12840
- switch (_context10.prev = _context10.next) {
12841
- case 0:
12842
- event = this.allocateEvent(FederatedPointerEvent);
12843
- this.copyPointerData(from, event);
12844
- this.copyMouseData(from, event);
12845
- this.copyData(from, event);
12846
- event.nativeEvent = from.nativeEvent;
12847
- event.originalEvent = from;
12848
- existedHTML = this.getExistedHTML(event);
12849
- if (!(target !== null && target !== void 0)) {
12850
- _context10.next = 11;
12851
- break;
12852
- }
12853
- _context10.t0 = target;
12854
- _context10.next = 20;
12855
- break;
12856
- case 11:
12857
- _context10.t1 = existedHTML;
12858
- if (_context10.t1) {
12859
- _context10.next = 19;
12860
- break;
12861
- }
12862
- _context10.t2 = this.isNativeEventFromCanvas(event);
12863
- if (!_context10.t2) {
12864
- _context10.next = 18;
12865
- break;
12866
- }
12867
- _context10.next = 17;
12868
- return this.pickTarget(event);
12869
- case 17:
12870
- _context10.t2 = _context10.sent;
12871
- case 18:
12872
- _context10.t1 = _context10.t2;
12873
- case 19:
12874
- _context10.t0 = _context10.t1;
12875
- case 20:
12876
- event.target = _context10.t0;
12877
- if (typeof type === 'string') {
12878
- event.type = type;
12879
- }
12880
- return _context10.abrupt("return", event);
12881
- case 23:
12882
- case "end":
12883
- return _context10.stop();
12884
- }
12885
- }
12886
- }, _callee10, this);
12887
- }));
12888
- function createPointerEvent(_x10, _x11, _x12) {
12889
- return _createPointerEvent.apply(this, arguments);
12890
- }
12891
- return createPointerEvent;
12892
- }();
12893
- _proto.createWheelEvent = /*#__PURE__*/function () {
12894
- var _createWheelEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(from) {
12895
- var event, existedHTML;
12896
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
12897
- while (1) {
12898
- switch (_context11.prev = _context11.next) {
12899
- case 0:
12900
- event = this.allocateEvent(FederatedWheelEvent);
12901
- this.copyWheelData(from, event);
12902
- this.copyMouseData(from, event);
12903
- this.copyData(from, event);
12904
- event.nativeEvent = from.nativeEvent;
12905
- event.originalEvent = from;
12906
- existedHTML = this.getExistedHTML(event);
12907
- _context11.t0 = existedHTML;
12908
- if (_context11.t0) {
12909
- _context11.next = 15;
12910
- break;
12911
- }
12912
- _context11.t1 = this.isNativeEventFromCanvas(event);
12913
- if (!_context11.t1) {
12914
- _context11.next = 14;
12915
- break;
12916
- }
12917
- _context11.next = 13;
12918
- return this.pickTarget(event);
12919
- case 13:
12920
- _context11.t1 = _context11.sent;
12921
- case 14:
12922
- _context11.t0 = _context11.t1;
12923
- case 15:
12924
- event.target = _context11.t0;
12925
- return _context11.abrupt("return", event);
12926
- case 17:
12927
- case "end":
12928
- return _context11.stop();
12929
- }
12930
- }
12931
- }, _callee11, this);
12932
- }));
12933
- function createWheelEvent(_x13) {
12934
- return _createWheelEvent.apply(this, arguments);
12859
+ _proto.pickTarget = function pickTarget(event) {
12860
+ return this.hitTest({
12861
+ clientX: event.clientX,
12862
+ clientY: event.clientY,
12863
+ viewportX: event.viewportX,
12864
+ viewportY: event.viewportY,
12865
+ x: event.canvasX,
12866
+ y: event.canvasY
12867
+ });
12868
+ };
12869
+ _proto.createPointerEvent = function createPointerEvent(from, type, target) {
12870
+ var event = this.allocateEvent(FederatedPointerEvent);
12871
+ this.copyPointerData(from, event);
12872
+ this.copyMouseData(from, event);
12873
+ this.copyData(from, event);
12874
+ event.nativeEvent = from.nativeEvent;
12875
+ event.originalEvent = from;
12876
+ var existedHTML = this.getExistedHTML(event);
12877
+ event.target = target !== null && target !== void 0 ? target : existedHTML || this.isNativeEventFromCanvas(event) && this.pickTarget(event);
12878
+ if (typeof type === 'string') {
12879
+ event.type = type;
12935
12880
  }
12936
- return createWheelEvent;
12937
- }();
12881
+ return event;
12882
+ };
12883
+ _proto.createWheelEvent = function createWheelEvent(from) {
12884
+ var event = this.allocateEvent(FederatedWheelEvent);
12885
+ this.copyWheelData(from, event);
12886
+ this.copyMouseData(from, event);
12887
+ this.copyData(from, event);
12888
+ event.nativeEvent = from.nativeEvent;
12889
+ event.originalEvent = from;
12890
+ var existedHTML = this.getExistedHTML(event);
12891
+ event.target = existedHTML || this.isNativeEventFromCanvas(event) && this.pickTarget(event);
12892
+ return event;
12893
+ };
12938
12894
  _proto.trackingData = function trackingData(id) {
12939
12895
  if (!this.mappingState.trackingData[id]) {
12940
12896
  this.mappingState.trackingData[id] = {
@@ -13191,6 +13147,9 @@ var RenderingService = /*#__PURE__*/function () {
13191
13147
  rendered: 0
13192
13148
  };
13193
13149
  this.zIndexCounter = 0;
13150
+ /**
13151
+ * avoid re-creating too many custom events
13152
+ */
13194
13153
  this.renderOrderChangedEvent = new CustomEvent(exports.ElementEvent.RENDER_ORDER_CHANGED);
13195
13154
  this.hooks = {
13196
13155
  /**
@@ -13240,7 +13199,8 @@ var RenderingService = /*#__PURE__*/function () {
13240
13199
  pointerOut: new SyncHook(['event']),
13241
13200
  pointerOver: new SyncHook(['event']),
13242
13201
  pointerWheel: new SyncHook(['event']),
13243
- pointerCancel: new SyncHook(['event'])
13202
+ pointerCancel: new SyncHook(['event']),
13203
+ click: new SyncHook(['event'])
13244
13204
  };
13245
13205
  this.globalRuntime = globalRuntime;
13246
13206
  this.context = context;
@@ -13250,22 +13210,20 @@ var RenderingService = /*#__PURE__*/function () {
13250
13210
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13251
13211
  var context;
13252
13212
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13253
- while (1) {
13254
- switch (_context.prev = _context.next) {
13255
- case 0:
13256
- context = _extends({}, this.globalRuntime, this.context); // register rendering plugins
13257
- this.context.renderingPlugins.forEach(function (plugin) {
13258
- plugin.apply(context, runtime);
13259
- });
13260
- // await this.hooks.init.callPromise();
13261
- _context.next = 4;
13262
- return this.hooks.init.promise();
13263
- case 4:
13264
- this.inited = true;
13265
- case 5:
13266
- case "end":
13267
- return _context.stop();
13268
- }
13213
+ while (1) switch (_context.prev = _context.next) {
13214
+ case 0:
13215
+ context = _extends({}, this.globalRuntime, this.context); // register rendering plugins
13216
+ this.context.renderingPlugins.forEach(function (plugin) {
13217
+ plugin.apply(context, runtime);
13218
+ });
13219
+ // await this.hooks.init.callPromise();
13220
+ _context.next = 4;
13221
+ return this.hooks.init.promise();
13222
+ case 4:
13223
+ this.inited = true;
13224
+ case 5:
13225
+ case "end":
13226
+ return _context.stop();
13269
13227
  }
13270
13228
  }, _callee, this);
13271
13229
  }));
@@ -13510,6 +13468,9 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13510
13468
  this.runtime = void 0;
13511
13469
  this.pendingEvents = [];
13512
13470
  this.boundsChangedEvent = new CustomEvent(exports.ElementEvent.BOUNDS_CHANGED);
13471
+ /**
13472
+ * rotate in world space
13473
+ */
13513
13474
  this.rotate = function () {
13514
13475
  var parentInvertRotation = glMatrix.quat.create();
13515
13476
  return function (element, degrees, y, z) {
@@ -13539,6 +13500,10 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13539
13500
  }
13540
13501
  };
13541
13502
  }();
13503
+ /**
13504
+ * rotate in local space
13505
+ * @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
13506
+ */
13542
13507
  this.rotateLocal = function () {
13543
13508
  var rotation = glMatrix.quat.create();
13544
13509
  return function (element, degrees, y, z) {
@@ -13557,6 +13522,9 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13557
13522
  _this.dirtifyLocal(element, transform);
13558
13523
  };
13559
13524
  }();
13525
+ /**
13526
+ * set euler angles(degrees) in world space
13527
+ */
13560
13528
  this.setEulerAngles = function () {
13561
13529
  var invParentRot = glMatrix.quat.create();
13562
13530
  return function (element, degrees, y, z) {
@@ -13581,6 +13549,15 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13581
13549
  }
13582
13550
  };
13583
13551
  }();
13552
+ /**
13553
+ * translate in local space
13554
+ *
13555
+ * @example
13556
+ * ```
13557
+ * translateLocal(x, y, z)
13558
+ * translateLocal(vec3(x, y, z))
13559
+ * ```
13560
+ */
13584
13561
  this.translateLocal = function () {
13585
13562
  return function (element, translation, y, z) {
13586
13563
  if (y === void 0) {
@@ -13601,6 +13578,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13601
13578
  _this.dirtifyLocal(element, transform);
13602
13579
  };
13603
13580
  }();
13581
+ /**
13582
+ * move to position in world space
13583
+ *
13584
+ * 对应 g 原版的 move/moveTo
13585
+ * @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
13586
+ */
13604
13587
  this.setPosition = function () {
13605
13588
  var parentInvertMatrix = glMatrix.mat4.create();
13606
13589
  var tmpPosition = glMatrix.vec3.create();
@@ -13624,6 +13607,9 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13624
13607
  _this.dirtifyLocal(element, transform);
13625
13608
  };
13626
13609
  }();
13610
+ /**
13611
+ * move to position in local space
13612
+ */
13627
13613
  this.setLocalPosition = function () {
13628
13614
  var tmpPosition = glMatrix.vec3.create();
13629
13615
  return function (element, position) {
@@ -13638,6 +13624,18 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13638
13624
  _this.dirtifyLocal(element, transform);
13639
13625
  };
13640
13626
  }();
13627
+ /**
13628
+ * translate in world space
13629
+ *
13630
+ * @example
13631
+ * ```
13632
+ * translate(x, y, z)
13633
+ * translate(vec3(x, y, z))
13634
+ * ```
13635
+ *
13636
+ * 对应 g 原版的 translate 2D
13637
+ * @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
13638
+ */
13641
13639
  this.translate = function () {
13642
13640
  var zeroVec3 = glMatrix.vec3.create();
13643
13641
  var tmpVec3 = glMatrix.vec3.create();
@@ -13804,10 +13802,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13804
13802
  originVec[1] = origin[1];
13805
13803
  originVec[2] = origin[2] || 0;
13806
13804
  this.dirtifyLocal(element, transform);
13807
- }
13808
- /**
13809
- * rotate in world space
13810
- */;
13805
+ };
13811
13806
  /**
13812
13807
  * set euler angles(degrees) in local space
13813
13808
  */
@@ -13824,16 +13819,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13824
13819
  var transform = element.transformable;
13825
13820
  glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
13826
13821
  this.dirtifyLocal(element, transform);
13827
- }
13828
- /**
13829
- * translate in local space
13830
- *
13831
- * @example
13832
- * ```
13833
- * translateLocal(x, y, z)
13834
- * translateLocal(vec3(x, y, z))
13835
- * ```
13836
- */;
13822
+ };
13837
13823
  /**
13838
13824
  * scale in local space
13839
13825
  */
@@ -13850,19 +13836,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13850
13836
  }
13851
13837
  glMatrix.vec3.copy(transform.localScale, updatedScaling);
13852
13838
  this.dirtifyLocal(element, transform);
13853
- }
13854
- /**
13855
- * translate in world space
13856
- *
13857
- * @example
13858
- * ```
13859
- * translate(x, y, z)
13860
- * translate(vec3(x, y, z))
13861
- * ```
13862
- *
13863
- * 对应 g 原版的 translate 2D
13864
- * @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
13865
- */;
13839
+ };
13866
13840
  _proto.setLocalRotation = function setLocalRotation(element, rotation, y, z, w) {
13867
13841
  if (typeof rotation === 'number') {
13868
13842
  rotation = glMatrix.quat.fromValues(rotation, y, z, w);
@@ -14271,6 +14245,9 @@ var TextService = /*#__PURE__*/function () {
14271
14245
  function TextService(runtime) {
14272
14246
  var _this = this;
14273
14247
  this.runtime = void 0;
14248
+ /**
14249
+ * font metrics cache
14250
+ */
14274
14251
  this.fontMetricsCache = {};
14275
14252
  this.shouldBreakByKinsokuShorui = function (char, nextChar) {
14276
14253
  if (_this.isBreakingSpace(nextChar)) return false;
@@ -14295,9 +14272,6 @@ var TextService = /*#__PURE__*/function () {
14295
14272
  };
14296
14273
  this.runtime = runtime;
14297
14274
  }
14298
- /**
14299
- * font metrics cache
14300
- */
14301
14275
  var _proto = TextService.prototype;
14302
14276
  /**
14303
14277
  * Calculates the ascent, descent and fontSize of a given font-style.
@@ -14386,9 +14360,8 @@ var TextService = /*#__PURE__*/function () {
14386
14360
  _parsedStyle$leading = parsedStyle.leading,
14387
14361
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
14388
14362
  var font = toFontString(parsedStyle);
14389
- var fontProperties;
14390
14363
  // if (runtime.enableCSSParsing) {
14391
- fontProperties = this.measureFont(font, offscreenCanvas);
14364
+ var fontProperties = this.measureFont(font, offscreenCanvas);
14392
14365
  // fallback in case UA disallow canvas data extraction
14393
14366
  // (toDataURI, getImageData functions)
14394
14367
  if (fontProperties.fontSize === 0) {
@@ -14860,34 +14833,15 @@ var EventPlugin = /*#__PURE__*/function () {
14860
14833
  this.context = context;
14861
14834
  var renderingService = context.renderingService;
14862
14835
  var canvas = this.context.renderingContext.root.ownerDocument.defaultView;
14863
- this.context.eventService.setPickHandler( /*#__PURE__*/function () {
14864
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(position) {
14865
- var _yield$_this2$context, picked;
14866
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14867
- while (1) {
14868
- switch (_context.prev = _context.next) {
14869
- case 0:
14870
- _context.next = 2;
14871
- return _this2.context.renderingService.hooks.pick.promise({
14872
- position: position,
14873
- picked: [],
14874
- topmost: true // we only concern the topmost element
14875
- });
14876
- case 2:
14877
- _yield$_this2$context = _context.sent;
14878
- picked = _yield$_this2$context.picked;
14879
- return _context.abrupt("return", picked[0] || null);
14880
- case 5:
14881
- case "end":
14882
- return _context.stop();
14883
- }
14884
- }
14885
- }, _callee);
14886
- }));
14887
- return function (_x) {
14888
- return _ref.apply(this, arguments);
14889
- };
14890
- }());
14836
+ this.context.eventService.setPickHandler(function (position) {
14837
+ var _this2$context$render = _this2.context.renderingService.hooks.pickSync.call({
14838
+ position: position,
14839
+ picked: [],
14840
+ topmost: true // we only concern the topmost element
14841
+ }),
14842
+ picked = _this2$context$render.picked;
14843
+ return picked[0] || null;
14844
+ });
14891
14845
  renderingService.hooks.pointerWheel.tap(EventPlugin.tag, function (nativeEvent) {
14892
14846
  var wheelEvent = _this2.normalizeWheelEvent(nativeEvent);
14893
14847
  _this2.context.eventService.mapEvent(wheelEvent);
@@ -14931,6 +14885,16 @@ var EventPlugin = /*#__PURE__*/function () {
14931
14885
  renderingService.hooks.pointerMove.tap(EventPlugin.tag, this.onPointerMove);
14932
14886
  renderingService.hooks.pointerOver.tap(EventPlugin.tag, this.onPointerMove);
14933
14887
  renderingService.hooks.pointerOut.tap(EventPlugin.tag, this.onPointerMove);
14888
+ renderingService.hooks.click.tap(EventPlugin.tag, this.onPointerMove);
14889
+ renderingService.hooks.pointerCancel.tap(EventPlugin.tag, function (nativeEvent) {
14890
+ var normalizedEvents = _this2.normalizeToPointerEvent(nativeEvent, canvas);
14891
+ for (var _iterator4 = _createForOfIteratorHelperLoose(normalizedEvents), _step4; !(_step4 = _iterator4()).done;) {
14892
+ var normalizedEvent = _step4.value;
14893
+ var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
14894
+ _this2.context.eventService.mapEvent(event);
14895
+ }
14896
+ _this2.setCursor(_this2.context.eventService.cursor);
14897
+ });
14934
14898
  };
14935
14899
  _proto.getViewportXY = function getViewportXY(nativeEvent) {
14936
14900
  var x;
@@ -15175,6 +15139,9 @@ var FrustumCullingStrategy = /*#__PURE__*/function () {
15175
15139
  var PrepareRendererPlugin = /*#__PURE__*/function () {
15176
15140
  function PrepareRendererPlugin() {
15177
15141
  this.rBush = void 0;
15142
+ /**
15143
+ * sync to RBush later
15144
+ */
15178
15145
  this.toSync = new Set();
15179
15146
  }
15180
15147
  var _proto = PrepareRendererPlugin.prototype;
@@ -15231,17 +15198,15 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
15231
15198
  };
15232
15199
  renderingService.hooks.init.tapPromise(PrepareRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15233
15200
  return _regeneratorRuntime().wrap(function _callee$(_context) {
15234
- while (1) {
15235
- switch (_context.prev = _context.next) {
15236
- case 0:
15237
- canvas.addEventListener(exports.ElementEvent.MOUNTED, handleMounted);
15238
- canvas.addEventListener(exports.ElementEvent.UNMOUNTED, handleUnmounted);
15239
- canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
15240
- canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
15241
- case 4:
15242
- case "end":
15243
- return _context.stop();
15244
- }
15201
+ while (1) switch (_context.prev = _context.next) {
15202
+ case 0:
15203
+ canvas.addEventListener(exports.ElementEvent.MOUNTED, handleMounted);
15204
+ canvas.addEventListener(exports.ElementEvent.UNMOUNTED, handleUnmounted);
15205
+ canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
15206
+ canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
15207
+ case 4:
15208
+ case "end":
15209
+ return _context.stop();
15245
15210
  }
15246
15211
  }, _callee);
15247
15212
  })));
@@ -15439,6 +15404,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15439
15404
  supportsPointerEvents = config.supportsPointerEvents,
15440
15405
  supportsTouchEvents = config.supportsTouchEvents,
15441
15406
  supportsCSSTransform = config.supportsCSSTransform,
15407
+ useNativeClickEvent = config.useNativeClickEvent,
15442
15408
  isTouchEvent = config.isTouchEvent,
15443
15409
  isMouseEvent = config.isMouseEvent;
15444
15410
  cleanExistedCanvas(container, _assertThisInitialized(_this));
@@ -15484,25 +15450,24 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15484
15450
  background: background || 'transparent',
15485
15451
  createImage: createImage,
15486
15452
  document: document,
15487
- supportsCSSTransform: supportsCSSTransform
15453
+ supportsCSSTransform: supportsCSSTransform,
15454
+ useNativeClickEvent: useNativeClickEvent
15488
15455
  });
15489
15456
  _this.initDefaultCamera(canvasWidth, canvasHeight);
15490
15457
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15491
15458
  return _regeneratorRuntime().wrap(function _callee$(_context) {
15492
- while (1) {
15493
- switch (_context.prev = _context.next) {
15494
- case 0:
15495
- _context.next = 2;
15496
- return _this.initRenderer(renderer);
15497
- case 2:
15498
- _this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
15499
- if (_this.readyPromise) {
15500
- _this.resolveReadyPromise();
15501
- }
15502
- case 4:
15503
- case "end":
15504
- return _context.stop();
15505
- }
15459
+ while (1) switch (_context.prev = _context.next) {
15460
+ case 0:
15461
+ _context.next = 2;
15462
+ return _this.initRenderer(renderer);
15463
+ case 2:
15464
+ _this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
15465
+ if (_this.readyPromise) {
15466
+ _this.resolveReadyPromise();
15467
+ }
15468
+ case 4:
15469
+ case "end":
15470
+ return _context.stop();
15506
15471
  }
15507
15472
  }, _callee);
15508
15473
  }))();
@@ -15690,56 +15655,54 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15690
15655
  _proto.initRenderer = /*#__PURE__*/function () {
15691
15656
  var _initRenderer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer) {
15692
15657
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
15693
- while (1) {
15694
- switch (_context2.prev = _context2.next) {
15695
- case 0:
15696
- if (renderer) {
15697
- _context2.next = 2;
15698
- break;
15699
- }
15700
- throw new Error('Renderer is required.');
15701
- case 2:
15702
- // reset
15703
- this.inited = false;
15704
- this.readyPromise = undefined;
15705
- // FIXME: should re-create here?
15706
- this.context.rBushRoot = new RBush__default['default']();
15707
- // reset rendering plugins
15708
- this.context.renderingPlugins = [];
15709
- this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(), new DirtyCheckPlugin(), new CullingPlugin([new FrustumCullingStrategy()]));
15710
- //
15711
- this.loadRendererContainerModule(renderer);
15712
- // init context service
15713
- this.context.contextService = new this.context.ContextService(_extends({}, runtime, this.context));
15714
- // init rendering service
15715
- this.context.renderingService = new RenderingService(runtime, this.context);
15716
- // init event service
15717
- this.context.eventService = new EventService(runtime, this.context);
15718
- this.context.eventService.init();
15719
- _context2.next = 14;
15720
- return this.context.contextService.init();
15721
- case 14:
15722
- _context2.next = 16;
15723
- return this.context.renderingService.init();
15724
- case 16:
15725
- this.inited = true;
15726
- this.getRoot().forEach(function (node) {
15727
- var renderable = node.renderable;
15728
- if (renderable) {
15729
- renderable.renderBoundsDirty = true;
15730
- renderable.boundsDirty = true;
15731
- renderable.dirty = true;
15732
- }
15733
- });
15734
- // keep current scenegraph unchanged, just trigger mounted event
15735
- this.mountChildren(this.getRoot());
15736
- if (renderer.getConfig().enableAutoRendering) {
15737
- this.run();
15658
+ while (1) switch (_context2.prev = _context2.next) {
15659
+ case 0:
15660
+ if (renderer) {
15661
+ _context2.next = 2;
15662
+ break;
15663
+ }
15664
+ throw new Error('Renderer is required.');
15665
+ case 2:
15666
+ // reset
15667
+ this.inited = false;
15668
+ this.readyPromise = undefined;
15669
+ // FIXME: should re-create here?
15670
+ this.context.rBushRoot = new RBush__default['default']();
15671
+ // reset rendering plugins
15672
+ this.context.renderingPlugins = [];
15673
+ this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(), new DirtyCheckPlugin(), new CullingPlugin([new FrustumCullingStrategy()]));
15674
+ //
15675
+ this.loadRendererContainerModule(renderer);
15676
+ // init context service
15677
+ this.context.contextService = new this.context.ContextService(_extends({}, runtime, this.context));
15678
+ // init rendering service
15679
+ this.context.renderingService = new RenderingService(runtime, this.context);
15680
+ // init event service
15681
+ this.context.eventService = new EventService(runtime, this.context);
15682
+ this.context.eventService.init();
15683
+ _context2.next = 14;
15684
+ return this.context.contextService.init();
15685
+ case 14:
15686
+ _context2.next = 16;
15687
+ return this.context.renderingService.init();
15688
+ case 16:
15689
+ this.inited = true;
15690
+ this.getRoot().forEach(function (node) {
15691
+ var renderable = node.renderable;
15692
+ if (renderable) {
15693
+ renderable.renderBoundsDirty = true;
15694
+ renderable.boundsDirty = true;
15695
+ renderable.dirty = true;
15738
15696
  }
15739
- case 20:
15740
- case "end":
15741
- return _context2.stop();
15742
- }
15697
+ });
15698
+ // keep current scenegraph unchanged, just trigger mounted event
15699
+ this.mountChildren(this.getRoot());
15700
+ if (renderer.getConfig().enableAutoRendering) {
15701
+ this.run();
15702
+ }
15703
+ case 20:
15704
+ case "end":
15705
+ return _context2.stop();
15743
15706
  }
15744
15707
  }, _callee2, this);
15745
15708
  }));
@@ -15761,31 +15724,29 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15761
15724
  var _setRenderer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderer) {
15762
15725
  var canvasConfig, oldRenderer;
15763
15726
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
15764
- while (1) {
15765
- switch (_context3.prev = _context3.next) {
15766
- case 0:
15767
- // update canvas' config
15768
- canvasConfig = this.getConfig();
15769
- if (!(canvasConfig.renderer === renderer)) {
15770
- _context3.next = 3;
15771
- break;
15772
- }
15773
- return _context3.abrupt("return");
15774
- case 3:
15775
- oldRenderer = canvasConfig.renderer;
15776
- canvasConfig.renderer = renderer;
15777
- // keep all children undestroyed
15778
- this.destroy(false, true);
15779
- // destroy all plugins, reverse will mutate origin array
15780
- [].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
15781
- plugin.destroy(runtime);
15782
- });
15783
- _context3.next = 9;
15784
- return this.initRenderer(renderer);
15785
- case 9:
15786
- case "end":
15787
- return _context3.stop();
15788
- }
15727
+ while (1) switch (_context3.prev = _context3.next) {
15728
+ case 0:
15729
+ // update canvas' config
15730
+ canvasConfig = this.getConfig();
15731
+ if (!(canvasConfig.renderer === renderer)) {
15732
+ _context3.next = 3;
15733
+ break;
15734
+ }
15735
+ return _context3.abrupt("return");
15736
+ case 3:
15737
+ oldRenderer = canvasConfig.renderer;
15738
+ canvasConfig.renderer = renderer;
15739
+ // keep all children undestroyed
15740
+ this.destroy(false, true);
15741
+ // destroy all plugins, reverse will mutate origin array
15742
+ [].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
15743
+ plugin.destroy(runtime);
15744
+ });
15745
+ _context3.next = 9;
15746
+ return this.initRenderer(renderer);
15747
+ case 9:
15748
+ case "end":
15749
+ return _context3.stop();
15789
15750
  }
15790
15751
  }, _callee3, this);
15791
15752
  }));