@antv/g-lite 1.3.0-next.3 → 1.3.0-next.6

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.
@@ -1,5 +1,9 @@
1
1
  import type { AABB } from '../shapes';
2
2
  export interface Geometry {
3
+ /**
4
+ * Need re-compute bounds.
5
+ */
6
+ dirty: boolean;
3
7
  /**
4
8
  * excluding all children
5
9
  */
@@ -49,6 +49,6 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
49
49
  * update geometry when relative props changed,
50
50
  * eg. r of Circle, width/height of Rect
51
51
  */
52
- private updateGeometry;
52
+ updateGeometry(object: DisplayObject): void;
53
53
  private isPropertyInheritable;
54
54
  }
@@ -11,6 +11,7 @@ export declare function resetEntityCounter(): void;
11
11
  * * Animation
12
12
  */
13
13
  export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends Node implements IElement<StyleProps, ParsedStyleProps> {
14
+ constructor();
14
15
  /**
15
16
  * Unique id.
16
17
  */
@@ -30,6 +30,7 @@ export declare abstract class Node extends EventTarget implements INode {
30
30
  */
31
31
  static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;
32
32
  static isNode(target: IEventTarget | INode): target is INode;
33
+ constructor();
33
34
  shadow: boolean;
34
35
  /**
35
36
  * points to canvas.document
@@ -303,7 +303,7 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
303
303
  /**
304
304
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
305
305
  */
306
- setAttribute: <Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean) => void;
306
+ setAttribute: <Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean, memoize?: boolean) => void;
307
307
  /**
308
308
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
309
309
  */
package/dist/index.esm.js CHANGED
@@ -4117,8 +4117,7 @@ function convertPercentUnit(valueWithUnit, vec3Index, target) {
4117
4117
  else if (valueWithUnit.unit === UnitType.kPercentage && target) {
4118
4118
  var bounds = target.nodeName === Shape.GROUP
4119
4119
  ? target.getLocalBounds()
4120
- : // : target.getGeometryBounds();
4121
- target.geometry.contentBounds;
4120
+ : target.getGeometryBounds();
4122
4121
  return (valueWithUnit.value / 100) * bounds.halfExtents[vec3Index] * 2;
4123
4122
  }
4124
4123
  return 0;
@@ -6707,7 +6706,9 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6707
6706
  this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames_1);
6708
6707
  }
6709
6708
  if (needUpdateGeometry_1) {
6710
- this.updateGeometry(object);
6709
+ object.geometry.dirty = true;
6710
+ // FIXME setOrigin may have already dirtified to root.
6711
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6711
6712
  }
6712
6713
  return;
6713
6714
  }
@@ -6766,9 +6767,9 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6766
6767
  // }
6767
6768
  // update geometry
6768
6769
  if (needUpdateGeometry) {
6769
- // object.geometry.dirty = true;
6770
- // runtime.sceneGraphService.dirtifyToRoot(object);
6771
- this.updateGeometry(object);
6770
+ object.geometry.dirty = true;
6771
+ // FIXME setOrigin may have already dirtified to root.
6772
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6772
6773
  }
6773
6774
  attributeNames.forEach(function (name) {
6774
6775
  if (name in object.parsedStyle) {
@@ -7055,6 +7056,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7055
7056
  geometry_1.renderBounds.setMinMax(min, max);
7056
7057
  }
7057
7058
  });
7059
+ object.geometry.dirty = false;
7058
7060
  // if (nodeName === Shape.RECT) {
7059
7061
  // account for negative width / height of Rect
7060
7062
  // @see https://github.com/antvis/g/issues/957
@@ -7072,8 +7074,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7072
7074
  ? convertPercentUnit(transformOrigin[1], 1, object)
7073
7075
  : 0);
7074
7076
  object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7075
- // FIXME setOrigin may have already dirtified to root.
7076
- this.runtime.sceneGraphService.dirtifyToRoot(object);
7077
7077
  }
7078
7078
  };
7079
7079
  DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
@@ -8769,7 +8769,7 @@ var EventTarget = /** @class */ (function () {
8769
8769
  var Node = /** @class */ (function (_super) {
8770
8770
  __extends(Node, _super);
8771
8771
  function Node() {
8772
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
8772
+ var _this = _super.call(this) || this;
8773
8773
  _this.shadow = false;
8774
8774
  /**
8775
8775
  * points to canvas.document
@@ -10546,7 +10546,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10546
10546
  // .filter((node) => !node.shadow);
10547
10547
  };
10548
10548
  DefaultSceneGraphService.prototype.attach = function (child, parent, index) {
10549
- var _a, _b;
10549
+ var _a;
10550
10550
  var detached = false;
10551
10551
  if (child.parentNode) {
10552
10552
  detached = child.parentNode !== parent;
@@ -10562,7 +10562,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10562
10562
  // parent needs re-sort
10563
10563
  var sortable = parent.sortable;
10564
10564
  if (((_a = sortable === null || sortable === void 0 ? void 0 : sortable.sorted) === null || _a === void 0 ? void 0 : _a.length) ||
10565
- ((_b = child.style) === null || _b === void 0 ? void 0 : _b.zIndex)) {
10565
+ child.parsedStyle.zIndex) {
10566
10566
  if (sortable.dirtyChildren.indexOf(child) === -1) {
10567
10567
  sortable.dirtyChildren.push(child);
10568
10568
  }
@@ -10872,6 +10872,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
10872
10872
  DefaultSceneGraphService.prototype.getGeometryBounds = function (element, render) {
10873
10873
  if (render === void 0) { render = false; }
10874
10874
  var geometry = element.geometry;
10875
+ if (geometry.dirty) {
10876
+ runtime.styleValueRegistry.updateGeometry(element);
10877
+ }
10875
10878
  var bounds = render
10876
10879
  ? geometry.renderBounds
10877
10880
  : geometry.contentBounds || null;
@@ -11556,7 +11559,7 @@ var destroyEvent = new CustomEvent(ElementEvent.DESTROY);
11556
11559
  var Element = /** @class */ (function (_super) {
11557
11560
  __extends(Element, _super);
11558
11561
  function Element() {
11559
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
11562
+ var _this = _super.call(this) || this;
11560
11563
  /**
11561
11564
  * Unique id.
11562
11565
  */
@@ -11600,6 +11603,7 @@ var Element = /** @class */ (function (_super) {
11600
11603
  _this.geometry = {
11601
11604
  contentBounds: undefined,
11602
11605
  renderBounds: undefined,
11606
+ dirty: true,
11603
11607
  };
11604
11608
  _this.rBushNode = {
11605
11609
  aabb: undefined,
@@ -11783,11 +11787,8 @@ var Element = /** @class */ (function (_super) {
11783
11787
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11784
11788
  this.ownerDocument.defaultView.mountChildren(child);
11785
11789
  }
11786
- // @ts-ignore
11787
- if (child.isMutationObserved) {
11788
- insertedEvent.relatedNode = this;
11789
- child.dispatchEvent(insertedEvent);
11790
- }
11790
+ insertedEvent.relatedNode = this;
11791
+ child.dispatchEvent(insertedEvent);
11791
11792
  return child;
11792
11793
  };
11793
11794
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12229,8 +12230,6 @@ var DisplayObject = /** @class */ (function (_super) {
12229
12230
  // assign name, id to config
12230
12231
  // eg. group.get('name')
12231
12232
  _this.config = config;
12232
- // compatible with G 3.0
12233
- // this.config.interactive = this.config.capture ?? this.config.interactive;
12234
12233
  // init scene graph node
12235
12234
  _this.id = _this.config.id || '';
12236
12235
  _this.name = _this.config.name || '';
@@ -12238,23 +12237,6 @@ var DisplayObject = /** @class */ (function (_super) {
12238
12237
  _this.className = _this.config.className || _this.config.class;
12239
12238
  }
12240
12239
  _this.nodeName = _this.config.type || Shape.GROUP;
12241
- // // compatible with G 3.0
12242
- // this.config.style =
12243
- // this.config.style || this.config.attrs || ({} as StyleProps);
12244
- // // Object.assign(this.config.style, this.config.attrs);
12245
- // // this.config.style = {
12246
- // // // ...DEFAULT_STYLE_PROPS,
12247
- // // ...this.config.style,
12248
- // // ...this.config.attrs,
12249
- // // };
12250
- // if (this.config.visible != null) {
12251
- // this.config.style.visibility =
12252
- // this.config.visible === false ? 'hidden' : 'visible';
12253
- // }
12254
- // if (this.config.interactive != null) {
12255
- // this.config.style.pointerEvents =
12256
- // this.config.interactive === false ? 'none' : 'auto';
12257
- // }
12258
12240
  // merge parsed value
12259
12241
  Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12260
12242
  ? DEFAULT_PARSED_STYLE_PROPS
@@ -13014,7 +12996,7 @@ var Circle = /** @class */ (function (_super) {
13014
12996
  if (_a === void 0) { _a = {}; }
13015
12997
  var style = _a.style, rest = __rest(_a, ["style"]);
13016
12998
  return _super.call(this, __assign({ type: Shape.CIRCLE, style: runtime.enableCSSParsing
13017
- ? __assign({ cx: '', cy: '', r: '' }, style) : __assign({}, style), initialParsedStyle: {
12999
+ ? __assign({ cx: '', cy: '', r: '' }, style) : style, initialParsedStyle: {
13018
13000
  transformOrigin: runtime.enableCSSParsing
13019
13001
  ? null
13020
13002
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13051,7 +13033,7 @@ var Ellipse = /** @class */ (function (_super) {
13051
13033
  if (_a === void 0) { _a = {}; }
13052
13034
  var style = _a.style, rest = __rest(_a, ["style"]);
13053
13035
  return _super.call(this, __assign({ type: Shape.ELLIPSE, style: runtime.enableCSSParsing
13054
- ? __assign({ cx: '', cy: '', rx: '', ry: '' }, style) : __assign({}, style), initialParsedStyle: {
13036
+ ? __assign({ cx: '', cy: '', rx: '', ry: '' }, style) : style, initialParsedStyle: {
13055
13037
  transformOrigin: runtime.enableCSSParsing
13056
13038
  ? null
13057
13039
  : [PECENTAGE_50, PECENTAGE_50],