@antv/g-lite 1.0.63 → 1.0.64

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.umd.js CHANGED
@@ -7394,7 +7394,6 @@
7394
7394
  var zIndex1 = Number(o1.parsedStyle.zIndex);
7395
7395
  var zIndex2 = Number(o2.parsedStyle.zIndex);
7396
7396
  if (zIndex1 === zIndex2) {
7397
- // return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
7398
7397
  var parent = o1.parentNode;
7399
7398
  if (parent) {
7400
7399
  var children = parent.childNodes || [];
@@ -12312,6 +12311,19 @@
12312
12311
  this.parser = parseTransformOrigin;
12313
12312
  };
12314
12313
 
12314
+ /**
12315
+ * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
12316
+ */
12317
+ (function (Strategy) {
12318
+ Strategy[Strategy["Standard"] = 0] = "Standard";
12319
+ })(exports.Strategy || (exports.Strategy = {}));
12320
+
12321
+ (function (SortReason) {
12322
+ SortReason[SortReason["ADDED"] = 0] = "ADDED";
12323
+ SortReason[SortReason["REMOVED"] = 1] = "REMOVED";
12324
+ SortReason[SortReason["Z_INDEX_CHANGED"] = 2] = "Z_INDEX_CHANGED";
12325
+ })(exports.SortReason || (exports.SortReason = {}));
12326
+
12315
12327
  var CSSPropertyZIndex = /*#__PURE__*/function () {
12316
12328
  function CSSPropertyZIndex() {
12317
12329
  this.parser = parseNumber;
@@ -12331,6 +12343,7 @@
12331
12343
  // need re-sort on parent
12332
12344
  if (parentSortable) {
12333
12345
  parentSortable.dirty = true;
12346
+ parentSortable.dirtyReason = exports.SortReason.Z_INDEX_CHANGED;
12334
12347
  }
12335
12348
  }
12336
12349
  };
@@ -13766,13 +13779,6 @@
13766
13779
  return Document;
13767
13780
  }(Node);
13768
13781
 
13769
- /**
13770
- * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
13771
- */
13772
- (function (Strategy) {
13773
- Strategy[Strategy["Standard"] = 0] = "Standard";
13774
- })(exports.Strategy || (exports.Strategy = {}));
13775
-
13776
13782
  /**
13777
13783
  * built-in events for element
13778
13784
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
@@ -13806,11 +13812,6 @@
13806
13812
  */
13807
13813
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
13808
13814
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
13809
- // GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
13810
- /**
13811
- * trigger when z-index changed
13812
- */
13813
- ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
13814
13815
  ElementEvent["CULLED"] = "culled";
13815
13816
  })(exports.ElementEvent || (exports.ElementEvent = {}));
13816
13817
 
@@ -13886,16 +13887,6 @@
13886
13887
  dirtyFlag: false,
13887
13888
  localDirtyFlag: false,
13888
13889
  frozen: false,
13889
- // localPosition: vec3.fromValues(0, 0, 0),
13890
- // localRotation: quat.fromValues(0, 0, 0, 1),
13891
- // localScale: vec3.fromValues(1, 1, 1),
13892
- // localTransform: mat4.create(),
13893
- // localSkew: vec2.fromValues(0, 0),
13894
- // position: vec3.fromValues(0, 0, 0),
13895
- // rotation: quat.fromValues(0, 0, 0, 1),
13896
- // scaling: vec3.fromValues(1, 1, 1),
13897
- // worldTransform: mat4.create(),
13898
- // origin: vec3.fromValues(0, 0, 0),
13899
13890
  localPosition: [0, 0, 0],
13900
13891
  localRotation: [0, 0, 0, 1],
13901
13892
  localScale: [1, 1, 1],
@@ -13910,8 +13901,9 @@
13910
13901
  _this.sortable = {
13911
13902
  dirty: false,
13912
13903
  sorted: undefined,
13913
- lastSortedIndex: undefined,
13914
- renderOrder: 0
13904
+ renderOrder: 0,
13905
+ dirtyChildren: [],
13906
+ dirtyReason: undefined
13915
13907
  };
13916
13908
  _this.geometry = {
13917
13909
  contentBounds: undefined,
@@ -19297,10 +19289,6 @@
19297
19289
  rendered: 0
19298
19290
  };
19299
19291
  this.zIndexCounter = 0;
19300
- /**
19301
- * avoid re-creating too many custom events
19302
- */
19303
- this.renderOrderChangedEvent = new CustomEvent(exports.ElementEvent.RENDER_ORDER_CHANGED);
19304
19292
  this.hooks = {
19305
19293
  /**
19306
19294
  * called before any frame rendered
@@ -19441,26 +19429,60 @@
19441
19429
  displayObject.renderable.dirty = false;
19442
19430
  displayObject.sortable.renderOrder = this.zIndexCounter++;
19443
19431
  this.stats.total++;
19444
- // sort is very expensive, use cached result if posible
19432
+ // sort is very expensive, use cached result if possible
19445
19433
  var sortable = displayObject.sortable;
19446
- var renderOrderChanged = false;
19447
19434
  if (sortable.dirty) {
19448
- sortable.sorted = displayObject.childNodes.slice().sort(sortByZIndex);
19449
- renderOrderChanged = true;
19435
+ this.sort(displayObject, sortable);
19450
19436
  sortable.dirty = false;
19437
+ sortable.dirtyChildren = [];
19438
+ sortable.dirtyReason = undefined;
19451
19439
  }
19452
19440
  // recursive rendering its children
19453
19441
  (sortable.sorted || displayObject.childNodes).forEach(function (child) {
19454
19442
  _this2.renderDisplayObject(child, canvasConfig, renderingContext);
19455
19443
  });
19456
- if (renderOrderChanged) {
19457
- displayObject.forEach(function (child) {
19458
- _this2.renderOrderChangedEvent.target = child;
19459
- _this2.renderOrderChangedEvent.detail = {
19460
- renderOrder: child.sortable.renderOrder
19461
- };
19462
- child.ownerDocument.defaultView.dispatchEvent(_this2.renderOrderChangedEvent, true);
19444
+ };
19445
+ _proto.sort = function sort(displayObject, sortable) {
19446
+ if (sortable.sorted && sortable.dirtyReason !== exports.SortReason.Z_INDEX_CHANGED) {
19447
+ // avoid re-sorting the whole children list
19448
+ sortable.dirtyChildren.forEach(function (child) {
19449
+ var index = displayObject.childNodes.indexOf(child);
19450
+ if (index === -1) {
19451
+ // remove from sorted list
19452
+ var _index = sortable.sorted.indexOf(child);
19453
+ sortable.sorted.splice(_index, 1);
19454
+ } else {
19455
+ var zIndex = Number(child.parsedStyle.zIndex);
19456
+ var firstZIndex = Number(sortable.sorted[0].parsedStyle.zIndex);
19457
+ var lastZIndex = Number(sortable.sorted[sortable.sorted.length - 1].parsedStyle.zIndex);
19458
+ if (zIndex < firstZIndex) {
19459
+ sortable.sorted.unshift(child);
19460
+ } else if (zIndex > lastZIndex) {
19461
+ sortable.sorted.push(child);
19462
+ } else {
19463
+ // insert into sorted list
19464
+ for (var i = 0; i < sortable.sorted.length; i++) {
19465
+ var _sortable$sorted, _sortable$sorted$i;
19466
+ var prevZIndex = Number((_sortable$sorted = sortable.sorted[i - 1]) === null || _sortable$sorted === void 0 ? void 0 : _sortable$sorted.parsedStyle.zIndex) || -Infinity;
19467
+ var currentZIndex = Number((_sortable$sorted$i = sortable.sorted[i]) === null || _sortable$sorted$i === void 0 ? void 0 : _sortable$sorted$i.parsedStyle.zIndex);
19468
+ if (zIndex > prevZIndex && zIndex < currentZIndex) {
19469
+ sortable.sorted.splice(i, 0, child);
19470
+ break;
19471
+ }
19472
+ if (zIndex === currentZIndex) {
19473
+ var currentIndex = displayObject.childNodes.indexOf(sortable.sorted[i]);
19474
+ var nextIndex = displayObject.childNodes.indexOf(sortable.sorted[i + 1]) || Infinity;
19475
+ if (index > currentIndex && index < nextIndex) {
19476
+ sortable.sorted.splice(i + 1, 0, child);
19477
+ break;
19478
+ }
19479
+ }
19480
+ }
19481
+ }
19482
+ }
19463
19483
  });
19484
+ } else {
19485
+ sortable.sorted = displayObject.childNodes.slice().sort(sortByZIndex);
19464
19486
  }
19465
19487
  };
19466
19488
  _proto.destroy = function destroy() {
@@ -19879,9 +19901,11 @@
19879
19901
  // parent needs re-sort
19880
19902
  var sortable = parent.sortable;
19881
19903
  if ((sortable === null || sortable === void 0 ? void 0 : (_sortable$sorted = sortable.sorted) === null || _sortable$sorted === void 0 ? void 0 : _sortable$sorted.length) || ((_child$style = child.style) === null || _child$style === void 0 ? void 0 : _child$style.zIndex)) {
19904
+ sortable.dirtyChildren.push(child);
19882
19905
  // if (sortable) {
19883
19906
  // only child has z-Index
19884
19907
  sortable.dirty = true;
19908
+ sortable.dirtyReason = exports.SortReason.ADDED;
19885
19909
  }
19886
19910
  // this.updateGraphDepth(child);
19887
19911
  var transform = child.transformable;
@@ -19910,7 +19934,9 @@
19910
19934
  var sortable = child.parentNode.sortable;
19911
19935
  // if (sortable) {
19912
19936
  if ((sortable === null || sortable === void 0 ? void 0 : (_sortable$sorted2 = sortable.sorted) === null || _sortable$sorted2 === void 0 ? void 0 : _sortable$sorted2.length) || ((_child$style2 = child.style) === null || _child$style2 === void 0 ? void 0 : _child$style2.zIndex)) {
19937
+ sortable.dirtyChildren.push(child);
19913
19938
  sortable.dirty = true;
19939
+ sortable.dirtyReason = exports.SortReason.REMOVED;
19914
19940
  }
19915
19941
  var index = child.parentNode.childNodes.indexOf(child);
19916
19942
  if (index > -1) {