@tamagui/core 1.132.2 → 1.132.3

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.
@@ -11823,18 +11823,7 @@ var require_index_native12 = __commonJS({
11823
11823
  }));
11824
11824
  }
11825
11825
  if (import_constants.isClient && rAF) {
11826
- layoutOnAnimationFrame = function() {
11827
- if (strategy !== "off") {
11828
- if (frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
11829
- rAF(layoutOnAnimationFrame);
11830
- return;
11831
- }
11832
- frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), Nodes.forEach(function(node) {
11833
- updateLayoutIfChanged(node);
11834
- });
11835
- }
11836
- rAF(layoutOnAnimationFrame);
11837
- }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, supportsCheckVisibility = "checkVisibility" in document.body;
11826
+ supportsCheckVisibility = "checkVisibility" in document.body, BoundingRects = /* @__PURE__ */ new WeakMap();
11838
11827
  async function updateLayoutIfChanged(node) {
11839
11828
  if (IntersectionState.get(node) !== !1 && !(process.env.TAMAGUI_ONLAYOUT_VISIBILITY_CHECK === "1" && supportsCheckVisibility && !node.checkVisibility())) {
11840
11829
  var onLayout = LayoutHandlers.get(node);
@@ -11844,8 +11833,8 @@ var require_index_native12 = __commonJS({
11844
11833
  var nodeRect, parentRect;
11845
11834
  if (strategy === "async") {
11846
11835
  var [nr, pr] = await Promise.all([
11847
- getBoundingClientRectAsync(node),
11848
- getBoundingClientRectAsync(parentNode)
11836
+ BoundingRects.get(node) || getBoundingClientRectAsync(node),
11837
+ BoundingRects.get(parentNode) || getBoundingClientRectAsync(parentNode)
11849
11838
  ]);
11850
11839
  if (nr === !1 || pr === !1) return;
11851
11840
  nodeRect = nr, parentRect = pr;
@@ -11866,8 +11855,56 @@ var require_index_native12 = __commonJS({
11866
11855
  }
11867
11856
  }
11868
11857
  rAF(layoutOnAnimationFrame), frameCount = 0, userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP, RUN_EVERY_X_FRAMES = userSkipVal ? +userSkipVal : 10;
11858
+ async function layoutOnAnimationFrame() {
11859
+ if (strategy !== "off") {
11860
+ if (!Nodes.size || frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
11861
+ rAF(layoutOnAnimationFrame);
11862
+ return;
11863
+ }
11864
+ frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), await new Promise(function(res) {
11865
+ var io = new IntersectionObserver(function(entries) {
11866
+ io.disconnect();
11867
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
11868
+ try {
11869
+ for (var _iterator2 = entries[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
11870
+ var entry = _step2.value;
11871
+ BoundingRects.set(entry.target, entry.boundingClientRect);
11872
+ }
11873
+ } catch (err) {
11874
+ _didIteratorError2 = !0, _iteratorError2 = err;
11875
+ } finally {
11876
+ try {
11877
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
11878
+ } finally {
11879
+ if (_didIteratorError2) throw _iteratorError2;
11880
+ }
11881
+ }
11882
+ res();
11883
+ }, {
11884
+ threshold: 0
11885
+ }), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
11886
+ try {
11887
+ for (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
11888
+ var node = _step.value;
11889
+ node.parentElement instanceof HTMLElement && (io.observe(node), io.observe(node.parentElement));
11890
+ }
11891
+ } catch (err) {
11892
+ _didIteratorError = !0, _iteratorError = err;
11893
+ } finally {
11894
+ try {
11895
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
11896
+ } finally {
11897
+ if (_didIteratorError) throw _iteratorError;
11898
+ }
11899
+ }
11900
+ }), Nodes.forEach(function(node) {
11901
+ updateLayoutIfChanged(node);
11902
+ });
11903
+ }
11904
+ rAF(layoutOnAnimationFrame);
11905
+ }
11869
11906
  }
11870
- var layoutOnAnimationFrame, layoutOnAnimationFrame2, supportsCheckVisibility, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
11907
+ var supportsCheckVisibility, BoundingRects, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
11871
11908
  return {
11872
11909
  nativeEvent: {
11873
11910
  layout: getRelativeDimensions(nodeRect, parentRect),