@antv/g 5.0.16 → 5.0.19

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.
Files changed (58) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.d.ts +4 -1
  3. package/es/Canvas.js +5 -3
  4. package/es/display-objects/DisplayObject.d.ts +5 -0
  5. package/es/display-objects/DisplayObject.js +20 -0
  6. package/es/display-objects/Text.d.ts +23 -0
  7. package/es/display-objects/Text.js +56 -1
  8. package/es/dom/Animation.js +1 -1
  9. package/es/dom/Document.d.ts +1 -1
  10. package/es/dom/Document.js +2 -2
  11. package/es/dom/Element.d.ts +28 -0
  12. package/es/dom/Element.js +74 -1
  13. package/es/dom/FederatedEvent.d.ts +4 -1
  14. package/es/dom/interfaces.d.ts +3 -0
  15. package/es/plugins/EventPlugin.d.ts +1 -0
  16. package/es/plugins/EventPlugin.js +15 -5
  17. package/es/plugins/FrustumCullingStrategy.js +3 -2
  18. package/es/property-handlers/color.js +3 -1
  19. package/es/services/EventService.js +8 -2
  20. package/es/services/RenderingService.d.ts +12 -2
  21. package/es/services/RenderingService.js +21 -4
  22. package/es/services/SceneGraphService.js +8 -10
  23. package/es/services/aabb/TextUpdater.js +12 -0
  24. package/es/shapes/AABB.js +5 -0
  25. package/es/types.d.ts +6 -0
  26. package/es/utils/animation.js +1 -1
  27. package/es/utils/event.js +6 -5
  28. package/es/utils/index.d.ts +2 -0
  29. package/es/utils/index.js +3 -1
  30. package/lib/Canvas.d.ts +4 -1
  31. package/lib/Canvas.js +5 -3
  32. package/lib/display-objects/DisplayObject.d.ts +5 -0
  33. package/lib/display-objects/DisplayObject.js +21 -0
  34. package/lib/display-objects/Text.d.ts +23 -0
  35. package/lib/display-objects/Text.js +56 -1
  36. package/lib/dom/Animation.js +1 -1
  37. package/lib/dom/Document.d.ts +1 -1
  38. package/lib/dom/Document.js +3 -3
  39. package/lib/dom/Element.d.ts +28 -0
  40. package/lib/dom/Element.js +74 -1
  41. package/lib/dom/FederatedEvent.d.ts +4 -1
  42. package/lib/dom/interfaces.d.ts +3 -0
  43. package/lib/plugins/EventPlugin.d.ts +1 -0
  44. package/lib/plugins/EventPlugin.js +13 -5
  45. package/lib/plugins/FrustumCullingStrategy.js +2 -1
  46. package/lib/property-handlers/color.js +3 -1
  47. package/lib/services/EventService.js +8 -2
  48. package/lib/services/RenderingService.d.ts +12 -2
  49. package/lib/services/RenderingService.js +21 -4
  50. package/lib/services/SceneGraphService.js +8 -14
  51. package/lib/services/aabb/TextUpdater.js +12 -0
  52. package/lib/shapes/AABB.js +5 -0
  53. package/lib/types.d.ts +6 -0
  54. package/lib/utils/animation.js +1 -1
  55. package/lib/utils/event.js +6 -5
  56. package/lib/utils/index.d.ts +2 -0
  57. package/lib/utils/index.js +26 -0
  58. package/package.json +3 -3
package/es/Canvas.d.ts CHANGED
@@ -71,7 +71,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
71
71
  getRenderingContext(): RenderingContext;
72
72
  getStats(): {
73
73
  total: number;
74
- rendered: number;
74
+ rendered: number; /**
75
+ * window.document
76
+ */
77
+ renderedOnscreen: number;
75
78
  };
76
79
  /**
77
80
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
package/es/Canvas.js CHANGED
@@ -57,7 +57,8 @@ function (_super) {
57
57
  renderer = config.renderer,
58
58
  background = config.background,
59
59
  requestAnimationFrame = config.requestAnimationFrame,
60
- cancelAnimationFrame = config.cancelAnimationFrame;
60
+ cancelAnimationFrame = config.cancelAnimationFrame,
61
+ createImage = config.createImage;
61
62
  cleanExistedCanvas(container, _this);
62
63
  var canvasWidth = width;
63
64
  var canvasHeight = height;
@@ -83,7 +84,8 @@ function (_super) {
83
84
  renderer: renderer,
84
85
  devicePixelRatio: dpr,
85
86
  cursor: 'default',
86
- background: background // background: 'white',
87
+ background: background,
88
+ createImage: createImage // background: 'white',
87
89
 
88
90
  });
89
91
 
@@ -303,7 +305,7 @@ function (_super) {
303
305
 
304
306
  if (this.container.isBound(RenderingService)) {
305
307
  var renderingService = this.container.get(RenderingService);
306
- renderingService.render();
308
+ renderingService.render(this.getConfig());
307
309
  }
308
310
 
309
311
  this.emit(CanvasEvent.AFTER_RENDER, {});
@@ -48,6 +48,11 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
48
48
  * called when attributes get changed or initialized
49
49
  */
50
50
  private changeAttribute;
51
+ /**
52
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
53
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
54
+ */
55
+ getBBox(): DOMRect;
51
56
  setOrigin(position: vec3 | vec2 | number, y?: number, z?: number): this;
52
57
  getOrigin(): vec3;
53
58
  /**
@@ -10,6 +10,7 @@ import { createVec3, formatAttribute, fromRotationTranslationScale, getEuler, ra
10
10
  import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
11
11
  import { dirtifyToRoot } from '../services';
12
12
  import { MutationEvent } from '../dom/MutationEvent';
13
+ import { Rectangle } from '../shapes';
13
14
  var DEFAULT_STYLE_PROPS = {
14
15
  anchor: [0, 0, 0],
15
16
  origin: [0, 0, 0],
@@ -281,6 +282,25 @@ function (_super) {
281
282
  // });
282
283
  }; // #region transformable
283
284
 
285
+ /**
286
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
287
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
288
+ */
289
+
290
+
291
+ DisplayObject.prototype.getBBox = function () {
292
+ var aabb = this.getBounds();
293
+
294
+ var _a = __read(aabb.getMin(), 2),
295
+ left = _a[0],
296
+ top = _a[1];
297
+
298
+ var _b = __read(aabb.getMax(), 2),
299
+ right = _b[0],
300
+ bottom = _b[1];
301
+
302
+ return new Rectangle(left, top, right - left, bottom - top);
303
+ };
284
304
 
285
305
  DisplayObject.prototype.setOrigin = function (position, y, z) {
286
306
  if (y === void 0) {
@@ -62,7 +62,30 @@ export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
62
62
  dx?: ParsedElement;
63
63
  dy?: ParsedElement;
64
64
  }
65
+ /**
66
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
67
+ */
65
68
  export declare class Text extends DisplayObject<TextStyleProps, ParsedTextStyleProps> {
69
+ /**
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
71
+ */
72
+ LENGTHADJUST_SPACING: number;
73
+ LENGTHADJUST_SPACINGANDGLYPHS: number;
74
+ LENGTHADJUST_UNKNOWN: number;
66
75
  constructor({ style, ...rest }?: DisplayObjectConfig<TextStyleProps>);
76
+ lengthAdjust: SVGAnimatedEnumeration;
77
+ textLength: SVGAnimatedLength;
78
+ getCharNumAtPosition(point?: DOMPointInit): number;
79
+ /**
80
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
81
+ */
82
+ getComputedTextLength(): number;
83
+ getEndPositionOfChar(charnum: number): DOMPoint;
84
+ getExtentOfChar(charnum: number): DOMRect;
85
+ getNumberOfChars(): number;
86
+ getRotationOfChar(charnum: number): number;
87
+ getStartPositionOfChar(charnum: number): DOMPoint;
88
+ getSubStringLength(charnum: number, nchars: number): number;
89
+ selectSubString(charnum: number, nchars: number): void;
67
90
  getLineBoundingRects(): import("..").Rectangle[];
68
91
  }
@@ -1,6 +1,9 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import { Shape, LineJoin, LineCap } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ /**
5
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
6
+ */
4
7
 
5
8
  var Text =
6
9
  /** @class */
@@ -12,10 +15,12 @@ function (_super) {
12
15
  _a = {};
13
16
  }
14
17
 
18
+ var _this = this;
19
+
15
20
  var style = _a.style,
16
21
  rest = __rest(_a, ["style"]);
17
22
 
18
- return _super.call(this, __assign({
23
+ _this = _super.call(this, __assign({
19
24
  type: Shape.TEXT,
20
25
  style: __assign({
21
26
  text: '',
@@ -48,8 +53,58 @@ function (_super) {
48
53
  dy: 0
49
54
  }, style)
50
55
  }, rest)) || this;
56
+ /**
57
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
58
+ */
59
+
60
+ _this.LENGTHADJUST_SPACING = 1;
61
+ _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
62
+ _this.LENGTHADJUST_UNKNOWN = 0;
63
+ return _this;
51
64
  }
52
65
 
66
+ Text.prototype.getCharNumAtPosition = function (point) {
67
+ throw new Error('Method not implemented.');
68
+ };
69
+ /**
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
71
+ */
72
+
73
+
74
+ Text.prototype.getComputedTextLength = function () {
75
+ var _a;
76
+
77
+ return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
78
+ };
79
+
80
+ Text.prototype.getEndPositionOfChar = function (charnum) {
81
+ throw new Error('Method not implemented.');
82
+ };
83
+
84
+ Text.prototype.getExtentOfChar = function (charnum) {
85
+ throw new Error('Method not implemented.');
86
+ };
87
+
88
+ Text.prototype.getNumberOfChars = function () {
89
+ throw new Error('Method not implemented.');
90
+ };
91
+
92
+ Text.prototype.getRotationOfChar = function (charnum) {
93
+ throw new Error('Method not implemented.');
94
+ };
95
+
96
+ Text.prototype.getStartPositionOfChar = function (charnum) {
97
+ throw new Error('Method not implemented.');
98
+ };
99
+
100
+ Text.prototype.getSubStringLength = function (charnum, nchars) {
101
+ throw new Error('Method not implemented.');
102
+ };
103
+
104
+ Text.prototype.selectSubString = function (charnum, nchars) {
105
+ throw new Error('Method not implemented.');
106
+ };
107
+
53
108
  Text.prototype.getLineBoundingRects = function () {
54
109
  var _a;
55
110
 
@@ -232,7 +232,7 @@ function () {
232
232
  get: function get() {
233
233
  var _a;
234
234
 
235
- return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().activeDuration);
235
+ return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().endTime);
236
236
  },
237
237
  enumerable: false,
238
238
  configurable: true
@@ -1,6 +1,6 @@
1
1
  import { Node } from './Node';
2
2
  import { AnimationTimeline } from './AnimationTimeline';
3
- import { Group } from '../display-objects/Group';
3
+ import { Group } from '../display-objects';
4
4
  import type { DisplayObject } from '../display-objects/DisplayObject';
5
5
  import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
6
6
  import type { BaseStyleProps } from '../types';
@@ -1,7 +1,7 @@
1
1
  import { __extends } from "tslib";
2
2
  import { Node } from './Node';
3
3
  import { AnimationTimeline } from './AnimationTimeline';
4
- import { Group } from '../display-objects/Group';
4
+ import { Group, Text } from '../display-objects';
5
5
  import { TextAlign } from '../types';
6
6
  /**
7
7
  * the entry of DOM tree
@@ -83,7 +83,7 @@ function (_super) {
83
83
 
84
84
  if (!clazz) {
85
85
  console.warn('Unsupported tagName: ', tagName);
86
- clazz = Group;
86
+ clazz = tagName === 'tspan' ? Text : Group;
87
87
  }
88
88
 
89
89
  return new clazz(options);
@@ -46,6 +46,12 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
46
46
  interactive: boolean;
47
47
  scrollLeft: number;
48
48
  scrollTop: number;
49
+ /**
50
+ * We don't support border now
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
52
+ */
53
+ clientTop: number;
54
+ clientLeft: number;
49
55
  get tagName(): string;
50
56
  get children(): IElement[];
51
57
  get childElementCount(): number;
@@ -138,10 +144,22 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
138
144
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
139
145
  */
140
146
  readonly attributes: StyleProps;
147
+ /**
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
149
+ */
150
+ getAttributeNames(): string[];
141
151
  /**
142
152
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
143
153
  */
144
154
  getAttribute(name: keyof StyleProps): any;
155
+ /**
156
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
157
+ */
158
+ hasAttribute(qualifiedName: string): boolean;
159
+ /**
160
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
161
+ */
162
+ hasAttributes(): boolean;
145
163
  /**
146
164
  * should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
147
165
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
@@ -151,4 +169,14 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
151
169
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
152
170
  */
153
171
  setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
172
+ getAttributeNS(namespace: string, localName: string): string;
173
+ getAttributeNode(qualifiedName: string): Attr;
174
+ getAttributeNodeNS(namespace: string, localName: string): Attr;
175
+ hasAttributeNS(namespace: string, localName: string): boolean;
176
+ removeAttributeNS(namespace: string, localName: string): void;
177
+ removeAttributeNode(attr: Attr): Attr;
178
+ setAttributeNS(namespace: string, qualifiedName: string, value: string): void;
179
+ setAttributeNode(attr: Attr): Attr;
180
+ setAttributeNodeNS(attr: Attr): Attr;
181
+ toggleAttribute(qualifiedName: string, force?: boolean): boolean;
154
182
  }
package/es/dom/Element.js CHANGED
@@ -37,6 +37,13 @@ function (_super) {
37
37
  _this.namespaceURI = 'g';
38
38
  _this.scrollLeft = 0;
39
39
  _this.scrollTop = 0;
40
+ /**
41
+ * We don't support border now
42
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
43
+ */
44
+
45
+ _this.clientTop = 0;
46
+ _this.clientLeft = 0;
40
47
  /**
41
48
  * is destroyed or not
42
49
  */
@@ -80,7 +87,9 @@ function (_super) {
80
87
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
81
88
  */
82
89
  get: function get() {
83
- return this.className.split(' ');
90
+ return this.className.split(' ').filter(function (c) {
91
+ return c !== '';
92
+ });
84
93
  },
85
94
  enumerable: false,
86
95
  configurable: true
@@ -479,6 +488,14 @@ function (_super) {
479
488
  Element.prototype.getClientRects = function () {
480
489
  return [this.getBoundingClientRect()];
481
490
  };
491
+ /**
492
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
493
+ */
494
+
495
+
496
+ Element.prototype.getAttributeNames = function () {
497
+ return Object.keys(this.attributes);
498
+ };
482
499
  /**
483
500
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
484
501
  */
@@ -492,6 +509,22 @@ function (_super) {
492
509
 
493
510
  return isNil(value) ? null : value;
494
511
  };
512
+ /**
513
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
514
+ */
515
+
516
+
517
+ Element.prototype.hasAttribute = function (qualifiedName) {
518
+ return this.getAttributeNames().includes(qualifiedName);
519
+ };
520
+ /**
521
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
522
+ */
523
+
524
+
525
+ Element.prototype.hasAttributes = function () {
526
+ return !!this.getAttributeNames().length;
527
+ };
495
528
  /**
496
529
  * should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
497
530
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
@@ -515,6 +548,46 @@ function (_super) {
515
548
  this.attributes[attributeName] = value;
516
549
  };
517
550
 
551
+ Element.prototype.getAttributeNS = function (namespace, localName) {
552
+ throw new Error('Method not implemented.');
553
+ };
554
+
555
+ Element.prototype.getAttributeNode = function (qualifiedName) {
556
+ throw new Error('Method not implemented.');
557
+ };
558
+
559
+ Element.prototype.getAttributeNodeNS = function (namespace, localName) {
560
+ throw new Error('Method not implemented.');
561
+ };
562
+
563
+ Element.prototype.hasAttributeNS = function (namespace, localName) {
564
+ throw new Error('Method not implemented.');
565
+ };
566
+
567
+ Element.prototype.removeAttributeNS = function (namespace, localName) {
568
+ throw new Error('Method not implemented.');
569
+ };
570
+
571
+ Element.prototype.removeAttributeNode = function (attr) {
572
+ throw new Error('Method not implemented.');
573
+ };
574
+
575
+ Element.prototype.setAttributeNS = function (namespace, qualifiedName, value) {
576
+ throw new Error('Method not implemented.');
577
+ };
578
+
579
+ Element.prototype.setAttributeNode = function (attr) {
580
+ throw new Error('Method not implemented.');
581
+ };
582
+
583
+ Element.prototype.setAttributeNodeNS = function (attr) {
584
+ throw new Error('Method not implemented.');
585
+ };
586
+
587
+ Element.prototype.toggleAttribute = function (qualifiedName, force) {
588
+ throw new Error('Method not implemented.');
589
+ };
590
+
518
591
  return Element;
519
592
  }(Node);
520
593
 
@@ -127,13 +127,16 @@ export declare class FederatedEvent<N extends Event = Event, T = any> {
127
127
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
128
128
  */
129
129
  stopPropagation(): void;
130
+ /**
131
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
132
+ */
133
+ view: any;
130
134
  /**
131
135
  * added for compatibility with DOM Event,
132
136
  * deprecated props and methods
133
137
  */
134
138
  initEvent(): void;
135
139
  initUIEvent(): void;
136
- view: WindowProxy;
137
140
  which: number;
138
141
  returnValue: boolean;
139
142
  srcElement: IEventTarget;
@@ -303,6 +303,8 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
303
303
  getElementsByTagName: <E extends IElement = IElement>(tagName: string) => E[];
304
304
  scrollLeft: number;
305
305
  scrollTop: number;
306
+ clientLeft: number;
307
+ clientTop: number;
306
308
  /**
307
309
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
308
310
  */
@@ -315,6 +317,7 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
315
317
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
316
318
  */
317
319
  removeAttribute: (attributeName: keyof StyleProps) => void;
320
+ hasAttribute: (qualifiedName: string) => boolean;
318
321
  }
319
322
  export interface IDocument extends INode, IParentNode {
320
323
  /**
@@ -11,6 +11,7 @@ export declare class EventPlugin implements RenderingPlugin {
11
11
  private canvasConfig;
12
12
  private contextService;
13
13
  private renderingService;
14
+ private renderingContext;
14
15
  private eventService;
15
16
  private autoPreventDefault;
16
17
  private rootPointerEvent;
@@ -2,6 +2,7 @@ import { __awaiter, __decorate, __generator, __metadata, __values } from "tslib"
2
2
  import { inject, singleton } from 'mana-syringe';
3
3
  import { FederatedPointerEvent } from '../dom/FederatedPointerEvent';
4
4
  import { FederatedWheelEvent } from '../dom/FederatedWheelEvent';
5
+ import { RenderingContext } from '../services';
5
6
  import { ContextService, RenderingService, EventService, RenderingPluginContribution } from '../services';
6
7
  import { Point } from '../shapes';
7
8
  import { CanvasConfig } from '../types';
@@ -26,6 +27,8 @@ function () {
26
27
  this.onPointerMove = function (nativeEvent) {
27
28
  var e_1, _a;
28
29
 
30
+ var _b, _c;
31
+
29
32
  if (supportsTouchEvents && nativeEvent.pointerType === 'touch') return;
30
33
  var normalizedEvents = normalizeToPointerEvent(nativeEvent);
31
34
 
@@ -33,7 +36,7 @@ function () {
33
36
  for (var normalizedEvents_1 = __values(normalizedEvents), normalizedEvents_1_1 = normalizedEvents_1.next(); !normalizedEvents_1_1.done; normalizedEvents_1_1 = normalizedEvents_1.next()) {
34
37
  var normalizedEvent = normalizedEvents_1_1.value;
35
38
 
36
- var event_1 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent);
39
+ var event_1 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, (_c = (_b = _this.renderingContext.root) === null || _b === void 0 ? void 0 : _b.ownerDocument) === null || _c === void 0 ? void 0 : _c.defaultView);
37
40
 
38
41
  _this.eventService.mapEvent(event_1);
39
42
  }
@@ -88,6 +91,8 @@ function () {
88
91
  renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
89
92
  var e_2, _a;
90
93
 
94
+ var _b, _c;
95
+
91
96
  if (supportsTouchEvents && nativeEvent.pointerType === 'touch') {
92
97
  return;
93
98
  }
@@ -106,7 +111,7 @@ function () {
106
111
  for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
107
112
  var event_2 = events_1_1.value;
108
113
 
109
- var federatedEvent = _this.bootstrapEvent(_this.rootPointerEvent, event_2);
114
+ var federatedEvent = _this.bootstrapEvent(_this.rootPointerEvent, event_2, (_c = (_b = _this.renderingContext.root) === null || _b === void 0 ? void 0 : _b.ownerDocument) === null || _c === void 0 ? void 0 : _c.defaultView);
110
115
 
111
116
  _this.eventService.mapEvent(federatedEvent);
112
117
  }
@@ -127,6 +132,8 @@ function () {
127
132
  renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
128
133
  var e_3, _a;
129
134
 
135
+ var _b, _c;
136
+
130
137
  if (supportsTouchEvents && nativeEvent.pointerType === 'touch') return; // account for element in SVG
131
138
 
132
139
  var $element = _this.contextService.getDomElement();
@@ -140,7 +147,7 @@ function () {
140
147
  for (var normalizedEvents_2 = __values(normalizedEvents), normalizedEvents_2_1 = normalizedEvents_2.next(); !normalizedEvents_2_1.done; normalizedEvents_2_1 = normalizedEvents_2.next()) {
141
148
  var normalizedEvent = normalizedEvents_2_1.value;
142
149
 
143
- var event_3 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent);
150
+ var event_3 = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, (_c = (_b = _this.renderingContext.root) === null || _b === void 0 ? void 0 : _b.ownerDocument) === null || _c === void 0 ? void 0 : _c.defaultView);
144
151
 
145
152
  event_3.type += outside;
146
153
 
@@ -165,8 +172,9 @@ function () {
165
172
  renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
166
173
  };
167
174
 
168
- EventPlugin.prototype.bootstrapEvent = function (event, nativeEvent) {
169
- // @ts-ignore
175
+ EventPlugin.prototype.bootstrapEvent = function (event, nativeEvent, view) {
176
+ event.view = view; // @ts-ignore
177
+
170
178
  event._originalEvent = null;
171
179
  event.nativeEvent = nativeEvent;
172
180
  event.pointerId = nativeEvent.pointerId;
@@ -278,6 +286,8 @@ function () {
278
286
 
279
287
  __decorate([inject(RenderingService), __metadata("design:type", RenderingService)], EventPlugin.prototype, "renderingService", void 0);
280
288
 
289
+ __decorate([inject(RenderingContext), __metadata("design:type", Object)], EventPlugin.prototype, "renderingContext", void 0);
290
+
281
291
  __decorate([inject(EventService), __metadata("design:type", EventService)], EventPlugin.prototype, "eventService", void 0);
282
292
 
283
293
  EventPlugin = EventPlugin_1 = __decorate([singleton({
@@ -2,7 +2,7 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { inject, singleton } from 'mana-syringe';
3
3
  import { vec3 } from 'gl-matrix';
4
4
  import { CullingStrategyContribution } from './CullingPlugin';
5
- import { Mask } from '../shapes';
5
+ import { AABB, Mask } from '../shapes';
6
6
  import { DefaultCamera, Camera } from '../camera/Camera';
7
7
  import { Shape } from '..'; // group is not a 2d shape
8
8
 
@@ -14,6 +14,7 @@ function () {
14
14
  function FrustumCullingStrategy() {}
15
15
 
16
16
  FrustumCullingStrategy.prototype.isVisible = function (object) {
17
+ // return true;
17
18
  var _a, _b;
18
19
 
19
20
  var cullable = object.cullable;
@@ -24,7 +25,7 @@ function () {
24
25
 
25
26
  var renderBounds = object.getRenderBounds();
26
27
 
27
- if (!renderBounds) {
28
+ if (AABB.isEmpty(renderBounds)) {
28
29
  return false;
29
30
  } // get VP matrix from camera
30
31
 
@@ -84,7 +84,9 @@ export function parseColor(colorStr) {
84
84
  return {
85
85
  type: PARSED_COLOR_TYPE.Constant,
86
86
  value: rgba,
87
- formatted: color && "rgba(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ",").concat(color.opacity, ")") || 'rgba(0,0,0,0)'
87
+ formatted: // rgba(255,255,255,0) -> [NaN, NaN, NaN, 0]
88
+ // @see https://github.com/d3/d3-color/issues/52
89
+ color && "rgba(".concat(color.r || 0, ",").concat(color.g || 0, ",").concat(color.b || 0, ",").concat(color.opacity, ")") || 'rgba(0,0,0,0)'
88
90
  };
89
91
  }
90
92
  export function mergeColors(left, right) {
@@ -477,6 +477,12 @@ function (_super) {
477
477
  }
478
478
 
479
479
  EventService.prototype.init = function () {
480
+ // this.onPointerDown = this.onPointerDown.bind(this);
481
+ // this.onPointerMove = this.onPointerUp.bind(this);
482
+ // this.onPointerMove = this.onPointerMove.bind(this);
483
+ // this.onPointerUp = this.onPointerUp.bind(this);
484
+ // this.onPointerOut = this.onPointerOut.bind(this);
485
+ // this.onWheel = this.onWheel.bind(this);
480
486
  this.rootTarget = this.renderingContext.root.parentNode; // document
481
487
 
482
488
  this.addEventMapping('pointerdown', this.onPointerDown);
@@ -871,14 +877,14 @@ function (_super) {
871
877
  emitter.removeListener(type, listeners.fn, undefined, true);
872
878
  }
873
879
 
874
- listeners.fn.call(listeners.context, e);
880
+ listeners.fn.call(e.currentTarget || listeners.context, e); // listeners.fn.call(listeners.context, e);
875
881
  } else {
876
882
  for (var i = 0; i < listeners.length && !e.propagationImmediatelyStopped; i++) {
877
883
  if (listeners[i].once) {
878
884
  emitter.removeListener(type, listeners[i].fn, undefined, true);
879
885
  }
880
886
 
881
- listeners[i].fn.call(listeners[i].context, e);
887
+ listeners[i].fn.call(e.currentTarget || listeners[i].context, e); // listeners[i].fn.call(listeners[i].context, e);
882
888
  }
883
889
  }
884
890
  };
@@ -1,6 +1,6 @@
1
1
  import { Syringe } from 'mana-syringe';
2
2
  import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
3
- import type { DisplayObject } from '..';
3
+ import type { CanvasConfig, DisplayObject } from '..';
4
4
  import type { EventPosition, InteractivePointerEvent } from '../types';
5
5
  export interface RenderingPlugin {
6
6
  apply: (renderer: RenderingService) => void;
@@ -48,10 +48,20 @@ export declare class RenderingService {
48
48
  };
49
49
  init(): Promise<void>;
50
50
  getStats(): {
51
+ /**
52
+ * total display objects in scenegraph
53
+ */
51
54
  total: number;
55
+ /**
56
+ * number of display objects need to render in current frame
57
+ */
52
58
  rendered: number;
59
+ /**
60
+ * number of display objects displayed on screen
61
+ */
62
+ renderedOnscreen: number;
53
63
  };
54
- render(): void;
64
+ render(canvasConfig: Partial<CanvasConfig>): void;
55
65
  private renderDisplayObject;
56
66
  destroy(): void;
57
67
  dirtify(): void;