@zag-js/popover 0.0.0-dev-20220418173111 → 0.0.0-dev-20220425073521

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
@@ -379,10 +379,14 @@ function preventBodyScroll(opts) {
379
379
  const viewport = isDom() ? win.visualViewport : null;
380
380
  const docEl = doc.documentElement;
381
381
  function preventScrollStandard() {
382
- const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"));
383
- return () => fn == null ? void 0 : fn();
382
+ if (docEl.hasAttribute("scroll-lock"))
383
+ return;
384
+ const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), () => docEl.setAttribute("scroll-lock", "true"));
385
+ return pipe(fn, () => docEl.removeAttribute("scroll-lock"));
384
386
  }
385
387
  function preventScrollMobileSafari() {
388
+ if (docEl.hasAttribute("scroll-lock"))
389
+ return;
386
390
  let scrollable;
387
391
  let lastY = 0;
388
392
  let onTouchStart = (e2) => {
@@ -446,11 +450,12 @@ function preventBodyScroll(opts) {
446
450
  let scrollY = win.scrollY;
447
451
  let restoreStyles = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), setStyle(doc.body, "marginTop", `-${scrollY}px`));
448
452
  win.scrollTo(0, 0);
449
- let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll));
453
+ let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll), () => docEl.setAttribute("scroll-lock", "true"));
450
454
  return () => {
451
455
  restoreStyles();
452
456
  removeEvents();
453
457
  win.scrollTo(scrollX, scrollY);
458
+ docEl.removeAttribute("scroll-lock");
454
459
  };
455
460
  }
456
461
  if (disabled)