@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.mjs CHANGED
@@ -356,10 +356,14 @@ function preventBodyScroll(opts) {
356
356
  const viewport = isDom() ? win.visualViewport : null;
357
357
  const docEl = doc.documentElement;
358
358
  function preventScrollStandard() {
359
- const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"));
360
- return () => fn == null ? void 0 : fn();
359
+ if (docEl.hasAttribute("scroll-lock"))
360
+ return;
361
+ const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), () => docEl.setAttribute("scroll-lock", "true"));
362
+ return pipe(fn, () => docEl.removeAttribute("scroll-lock"));
361
363
  }
362
364
  function preventScrollMobileSafari() {
365
+ if (docEl.hasAttribute("scroll-lock"))
366
+ return;
363
367
  let scrollable;
364
368
  let lastY = 0;
365
369
  let onTouchStart = (e2) => {
@@ -423,11 +427,12 @@ function preventBodyScroll(opts) {
423
427
  let scrollY = win.scrollY;
424
428
  let restoreStyles = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), setStyle(doc.body, "marginTop", `-${scrollY}px`));
425
429
  win.scrollTo(0, 0);
426
- 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));
430
+ 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"));
427
431
  return () => {
428
432
  restoreStyles();
429
433
  removeEvents();
430
434
  win.scrollTo(scrollX, scrollY);
435
+ docEl.removeAttribute("scroll-lock");
431
436
  };
432
437
  }
433
438
  if (disabled)