@antv/g-lite 2.2.16 → 2.2.18

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