infinity-ui-elements 1.14.4 → 1.14.5

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
@@ -1566,32 +1566,55 @@ const BottomSheet = React__namespace.forwardRef(({ isOpen, onClose, title, descr
1566
1566
  document.body.style.right = "0";
1567
1567
  document.body.style.width = "100%";
1568
1568
  }
1569
+ // Track touch position for scroll boundary detection
1570
+ let lastTouchY = 0;
1571
+ const handleTouchStartForScroll = (e) => {
1572
+ lastTouchY = e.touches[0].clientY;
1573
+ };
1569
1574
  // Prevent touchmove on overlay to stop iOS rubber-banding
1575
+ // But always allow scrolling inside body content
1570
1576
  const preventTouchMove = (e) => {
1571
1577
  const target = e.target;
1572
- // Allow scrolling inside the body content
1578
+ const currentTouchY = e.touches[0].clientY;
1579
+ const touchDelta = currentTouchY - lastTouchY;
1580
+ lastTouchY = currentTouchY;
1581
+ // Always allow scrolling inside the body content
1573
1582
  if (bodyRef.current?.contains(target)) {
1574
1583
  const scrollTop = bodyRef.current.scrollTop;
1575
1584
  const scrollHeight = bodyRef.current.scrollHeight;
1576
1585
  const clientHeight = bodyRef.current.clientHeight;
1577
- // Check if at scroll boundaries
1578
- const isAtTop = scrollTop <= 0;
1579
- const isAtBottom = scrollTop + clientHeight >= scrollHeight;
1580
- // Only prevent default if at boundaries and trying to scroll further
1581
- if ((isAtTop && e.touches[0].clientY > (touchStart || 0)) ||
1582
- (isAtBottom && e.touches[0].clientY < (touchStart || 0))) {
1583
- // Allow the swipe-to-close gesture
1584
- if (!isDraggingFromHandle.current) {
1586
+ const canScroll = scrollHeight > clientHeight;
1587
+ // If content is scrollable, allow normal scrolling
1588
+ if (canScroll) {
1589
+ const isAtTop = scrollTop <= 0;
1590
+ const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
1591
+ const isScrollingDown = touchDelta > 0; // finger moving down = scrolling up
1592
+ const isScrollingUp = touchDelta < 0; // finger moving up = scrolling down
1593
+ // Only prevent at boundaries when trying to scroll beyond
1594
+ if ((isAtTop && isScrollingDown) || (isAtBottom && isScrollingUp)) {
1595
+ // At boundary, prevent overscroll but allow swipe-to-close from drag handle
1596
+ if (isDraggingFromHandle.current) {
1597
+ return; // Allow swipe gesture
1598
+ }
1585
1599
  e.preventDefault();
1586
1600
  }
1601
+ // Otherwise, allow normal scrolling
1602
+ return;
1587
1603
  }
1604
+ // Content not scrollable, allow touch events to pass through
1605
+ return;
1606
+ }
1607
+ // Also allow scrolling in sticky content area
1608
+ if (target.closest('[data-sticky-content]')) {
1588
1609
  return;
1589
1610
  }
1590
- // Prevent scroll on overlay and other areas
1611
+ // Prevent scroll on overlay and other areas (to prevent background scroll)
1591
1612
  e.preventDefault();
1592
1613
  };
1614
+ document.addEventListener("touchstart", handleTouchStartForScroll, { passive: true });
1593
1615
  document.addEventListener("touchmove", preventTouchMove, { passive: false });
1594
1616
  return () => {
1617
+ document.removeEventListener("touchstart", handleTouchStartForScroll);
1595
1618
  document.removeEventListener("touchmove", preventTouchMove);
1596
1619
  // Restore original styles
1597
1620
  if (originalBodyStyles.current) {