@dloizides/ui-layout 1.26.1 → 1.26.2

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
@@ -460,6 +460,10 @@ function observeLayout(node, onChange) {
460
460
  observer.observe(document.body);
461
461
  return observer;
462
462
  }
463
+ function isSameRect(a, b) {
464
+ if (a === null || b === null) return a === b;
465
+ return a.top === b.top && a.left === b.left && a.width === b.width && a.bottom === b.bottom;
466
+ }
463
467
  function useAnchorTracking(containerRef, onOutOfView) {
464
468
  const [rect, setRect] = React10.useState(() => readAnchorRect(containerRef));
465
469
  React10.useLayoutEffect(() => {
@@ -471,7 +475,7 @@ function useAnchorTracking(containerRef, onOutOfView) {
471
475
  frame = null;
472
476
  if (isDisposed) return;
473
477
  const next = readAnchorRect(containerRef);
474
- setRect(next);
478
+ setRect((previous) => isSameRect(previous, next) ? previous : next);
475
479
  const isHidden = next !== null && isAnchorHidden(next, readClipBounds(toDomNode(containerRef)), MIN_VISIBLE_PX);
476
480
  if (hasMeasured && isHidden) onOutOfView();
477
481
  hasMeasured = true;