@antv/g-lite 2.2.16 → 2.2.17

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.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-lite
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 2.2.16
5
- * @date 1/23/2025, 8:31:51 AM
4
+ * @version 2.2.17
5
+ * @date 4/11/2025, 8:15:28 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -10537,11 +10537,12 @@ var RenderingService = /*#__PURE__*/function () {
10537
10537
  }
10538
10538
  var stack = [displayObject];
10539
10539
  while (stack.length > 0) {
10540
+ var _currentObject$sortab;
10540
10541
  var currentObject = stack.pop();
10541
10542
  internalRenderSingleDisplayObject(currentObject);
10542
10543
 
10543
10544
  // recursive rendering its children
10544
- var objects = currentObject.sortable.sorted || currentObject.childNodes;
10545
+ var objects = ((_currentObject$sortab = currentObject.sortable) === null || _currentObject$sortab === void 0 || (_currentObject$sortab = _currentObject$sortab.sorted) === null || _currentObject$sortab === void 0 ? void 0 : _currentObject$sortab.length) > 0 ? currentObject.sortable.sorted : currentObject.childNodes;
10545
10546
  for (var i = objects.length - 1; i >= 0; i--) {
10546
10547
  stack.push(objects[i]);
10547
10548
  }
@@ -10550,26 +10551,35 @@ var RenderingService = /*#__PURE__*/function () {
10550
10551
  }, {
10551
10552
  key: "sort",
10552
10553
  value: function sort(displayObject, sortable) {
10554
+ var _sortable$sorted;
10553
10555
  if (sortable.sorted && sortable.dirtyReason !== SortReason.Z_INDEX_CHANGED) {
10554
10556
  // avoid re-sorting the whole children list
10555
10557
  sortable.dirtyChildren.forEach(function (child) {
10558
+ // remove from sorted list
10559
+ var sortIndex = sortable.sorted.indexOf(child);
10560
+ if (sortIndex > -1) {
10561
+ sortable.sorted.splice(sortIndex, 1);
10562
+ }
10556
10563
  var index = displayObject.childNodes.indexOf(child);
10557
- if (index === -1) {
10558
- // remove from sorted list
10559
- var _index = sortable.sorted.indexOf(child);
10560
- if (_index >= 0) {
10561
- sortable.sorted.splice(_index, 1);
10564
+ if (index > -1) {
10565
+ if (sortable.sorted.length === 0) {
10566
+ sortable.sorted.push(child);
10567
+ } else {
10568
+ var _index = sortedIndex(sortable.sorted, child);
10569
+ sortable.sorted.splice(_index, 0, child);
10562
10570
  }
10563
- } else if (sortable.sorted.length === 0) {
10564
- sortable.sorted.push(child);
10565
- } else {
10566
- var _index2 = sortedIndex(sortable.sorted, child);
10567
- sortable.sorted.splice(_index2, 0, child);
10568
10571
  }
10569
10572
  });
10570
10573
  } else {
10571
10574
  sortable.sorted = displayObject.childNodes.slice().sort(sortByZIndex);
10572
10575
  }
10576
+
10577
+ // When the child elements are changed and sorted, if there are no more stacked elements in the child elements (i.e. zIndex != 0), clear the sort list
10578
+ if (((_sortable$sorted = sortable.sorted) === null || _sortable$sorted === void 0 ? void 0 : _sortable$sorted.length) > 0 && displayObject.childNodes.filter(function (child) {
10579
+ return child.parsedStyle.zIndex;
10580
+ }).length === 0) {
10581
+ sortable.sorted = [];
10582
+ }
10573
10583
  }
10574
10584
  }, {
10575
10585
  key: "destroy",
@@ -10902,7 +10912,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
10902
10912
  // parent needs re-sort
10903
10913
  var _ref = parent,
10904
10914
  sortable = _ref.sortable;
10905
- if (sortable !== null && sortable !== void 0 && (_sortable$sorted = sortable.sorted) !== null && _sortable$sorted !== void 0 && _sortable$sorted.length || child.parsedStyle.zIndex) {
10915
+ if (sortable !== null && sortable !== void 0 && (_sortable$sorted = sortable.sorted) !== null && _sortable$sorted !== void 0 && _sortable$sorted.length || sortable.dirty || child.parsedStyle.zIndex) {
10906
10916
  if (sortable.dirtyChildren.indexOf(child) === -1) {
10907
10917
  sortable.dirtyChildren.push(child);
10908
10918
  }
@@ -10925,37 +10935,38 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
10925
10935
  }, {
10926
10936
  key: "detach",
10927
10937
  value: function detach(child) {
10928
- if (child.parentNode) {
10929
- var _sortable$sorted2, _style;
10930
- var transform = child.transformable;
10931
- // if (transform) {
10932
- // const worldTransform = this.getWorldTransform(child, transform);
10933
- // mat4.getScaling(transform.localScale, worldTransform);
10934
- // mat4.getTranslation(transform.localPosition, worldTransform);
10935
- // mat4.getRotation(transform.localRotation, worldTransform);
10936
- // transform.localDirtyFlag = true;
10937
- // }
10938
+ var _sortable$sorted2, _style;
10939
+ if (!child.parentNode) {
10940
+ return;
10941
+ }
10942
+ var transform = child.transformable;
10943
+ // if (transform) {
10944
+ // const worldTransform = this.getWorldTransform(child, transform);
10945
+ // mat4.getScaling(transform.localScale, worldTransform);
10946
+ // mat4.getTranslation(transform.localPosition, worldTransform);
10947
+ // mat4.getRotation(transform.localRotation, worldTransform);
10948
+ // transform.localDirtyFlag = true;
10949
+ // }
10938
10950
 
10939
- // parent needs re-sort
10940
- var _ref2 = child.parentNode,
10941
- sortable = _ref2.sortable;
10942
- // if (sortable) {
10943
- if (sortable !== null && sortable !== void 0 && (_sortable$sorted2 = sortable.sorted) !== null && _sortable$sorted2 !== void 0 && _sortable$sorted2.length || (_style = child.style) !== null && _style !== void 0 && _style.zIndex) {
10944
- if (sortable.dirtyChildren.indexOf(child) === -1) {
10945
- sortable.dirtyChildren.push(child);
10946
- }
10947
- sortable.dirty = true;
10948
- sortable.dirtyReason = SortReason.REMOVED;
10949
- }
10950
- var index = child.parentNode.childNodes.indexOf(child);
10951
- if (index > -1) {
10952
- child.parentNode.childNodes.splice(index, 1);
10953
- }
10954
- if (transform) {
10955
- this.dirtifyWorld(child, transform);
10951
+ // parent needs re-sort
10952
+ var _ref2 = child.parentNode,
10953
+ sortable = _ref2.sortable;
10954
+ // if (sortable) {
10955
+ if (sortable !== null && sortable !== void 0 && (_sortable$sorted2 = sortable.sorted) !== null && _sortable$sorted2 !== void 0 && _sortable$sorted2.length || (_style = child.style) !== null && _style !== void 0 && _style.zIndex) {
10956
+ if (sortable.dirtyChildren.indexOf(child) === -1) {
10957
+ sortable.dirtyChildren.push(child);
10956
10958
  }
10957
- child.parentNode = null;
10959
+ sortable.dirty = true;
10960
+ sortable.dirtyReason = SortReason.REMOVED;
10961
+ }
10962
+ var index = child.parentNode.childNodes.indexOf(child);
10963
+ if (index > -1) {
10964
+ child.parentNode.childNodes.splice(index, 1);
10965
+ }
10966
+ if (transform) {
10967
+ this.dirtifyWorld(child, transform);
10958
10968
  }
10969
+ child.parentNode = null;
10959
10970
  }
10960
10971
  }, {
10961
10972
  key: "getOrigin",