@ticketboothapp/booking 1.2.40 → 1.2.41
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/package.json
CHANGED
|
@@ -1423,86 +1423,59 @@ export function BookingFlow({
|
|
|
1423
1423
|
return null;
|
|
1424
1424
|
};
|
|
1425
1425
|
|
|
1426
|
-
const
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
const allowsScroll = style.overflowY === 'auto' || style.overflowY === 'scroll' || style.overflowY === 'overlay';
|
|
1432
|
-
return allowsScroll && node.scrollHeight > node.clientHeight + 1;
|
|
1433
|
-
};
|
|
1434
|
-
|
|
1435
|
-
// Deterministic host-aware choice:
|
|
1436
|
-
// 1) explicit contentRef when it is truly scrollable
|
|
1437
|
-
// 2) nearest detected scroll parent when it is truly scrollable
|
|
1438
|
-
// 3) window scroll
|
|
1439
|
-
const scrollParent =
|
|
1440
|
-
!useWindowScroll && isElementScrollable(explicitScrollContainer)
|
|
1441
|
-
? explicitScrollContainer
|
|
1442
|
-
: !useWindowScroll && isElementScrollable(detectedScrollParent)
|
|
1443
|
-
? detectedScrollParent
|
|
1444
|
-
: null;
|
|
1445
|
-
const scrollTarget = scrollParent ?? (typeof window !== 'undefined' ? window : null);
|
|
1426
|
+
const scrollParent = findScrollParent(el);
|
|
1427
|
+
const scrollTarget =
|
|
1428
|
+
useWindowScroll || !scrollParent
|
|
1429
|
+
? (typeof window !== 'undefined' ? window : null)
|
|
1430
|
+
: scrollParent;
|
|
1446
1431
|
|
|
1432
|
+
let ticking = false;
|
|
1447
1433
|
const COOLDOWN_MS = 600; // After a state change, ignore reverse changes for this long (covers 0.25s collapse animation + layout settle)
|
|
1448
|
-
const
|
|
1449
|
-
const wasSticky = isItineraryStickyRef.current;
|
|
1450
|
-
if (nextSticky === wasSticky) return;
|
|
1451
|
-
const now = Date.now();
|
|
1452
|
-
if (now - lastStickyChangeRef.current < COOLDOWN_MS) return;
|
|
1453
|
-
lastStickyChangeRef.current = now;
|
|
1454
|
-
isItineraryStickyRef.current = nextSticky;
|
|
1455
|
-
setIsItinerarySticky(nextSticky);
|
|
1456
|
-
};
|
|
1457
|
-
|
|
1458
|
-
const topInset = Math.max(0, flowUi?.itineraryStickyTopOffsetPx ?? 0);
|
|
1459
|
-
|
|
1460
|
-
// Primary path: IntersectionObserver sentinel is reliable across nested scroll containers.
|
|
1461
|
-
if (typeof window !== 'undefined' && 'IntersectionObserver' in window) {
|
|
1462
|
-
const sentinel = document.createElement('div');
|
|
1463
|
-
sentinel.setAttribute('data-itinerary-sticky-sentinel', 'true');
|
|
1464
|
-
sentinel.style.height = '1px';
|
|
1465
|
-
sentinel.style.margin = '0';
|
|
1466
|
-
sentinel.style.padding = '0';
|
|
1467
|
-
sentinel.style.pointerEvents = 'none';
|
|
1468
|
-
el.parentElement?.insertBefore(sentinel, el);
|
|
1469
|
-
|
|
1470
|
-
const observer = new IntersectionObserver(
|
|
1471
|
-
(entries) => {
|
|
1472
|
-
const entry = entries[0];
|
|
1473
|
-
// When sentinel leaves the visible root area (adjusted by top inset), itinerary is sticky.
|
|
1474
|
-
setStickyState(!entry.isIntersecting);
|
|
1475
|
-
},
|
|
1476
|
-
{
|
|
1477
|
-
root: scrollParent,
|
|
1478
|
-
rootMargin: `${-topInset}px 0px 0px 0px`,
|
|
1479
|
-
threshold: 0,
|
|
1480
|
-
},
|
|
1481
|
-
);
|
|
1482
|
-
|
|
1483
|
-
observer.observe(sentinel);
|
|
1484
|
-
return () => {
|
|
1485
|
-
observer.disconnect();
|
|
1486
|
-
sentinel.remove();
|
|
1487
|
-
};
|
|
1488
|
-
}
|
|
1434
|
+
const atTopBand = 48; // px - must scroll back up past this band to expand again (wider = less oscillation at edges)
|
|
1489
1435
|
|
|
1490
|
-
// Fallback path for environments without IntersectionObserver.
|
|
1491
1436
|
const updateStickyState = () => {
|
|
1492
1437
|
if (!itineraryRef.current) return;
|
|
1438
|
+
|
|
1493
1439
|
const rect = itineraryRef.current.getBoundingClientRect();
|
|
1440
|
+
const currentTop = rect.top;
|
|
1441
|
+
const wasSticky = isItineraryStickyRef.current;
|
|
1442
|
+
|
|
1494
1443
|
const containerTop =
|
|
1495
1444
|
scrollParent && !useWindowScroll ? scrollParent.getBoundingClientRect().top : 0;
|
|
1496
|
-
|
|
1445
|
+
const topInset = Math.max(0, flowUi?.itineraryStickyTopOffsetPx ?? 0);
|
|
1446
|
+
const stickLine = containerTop + topInset;
|
|
1447
|
+
const enterStickyThreshold = stickLine + 1;
|
|
1448
|
+
const nextSticky = wasSticky
|
|
1449
|
+
? currentTop >= stickLine - atTopBand && currentTop <= stickLine + atTopBand
|
|
1450
|
+
: currentTop <= enterStickyThreshold;
|
|
1451
|
+
|
|
1452
|
+
if (nextSticky !== wasSticky) {
|
|
1453
|
+
const now = Date.now();
|
|
1454
|
+
if (now - lastStickyChangeRef.current < COOLDOWN_MS) return; // Cooldown: prevent rapid toggling
|
|
1455
|
+
|
|
1456
|
+
lastStickyChangeRef.current = now;
|
|
1457
|
+
isItineraryStickyRef.current = nextSticky;
|
|
1458
|
+
setIsItinerarySticky(nextSticky);
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
const handleScroll = () => {
|
|
1463
|
+
if (!ticking) {
|
|
1464
|
+
window.requestAnimationFrame(() => {
|
|
1465
|
+
updateStickyState();
|
|
1466
|
+
ticking = false;
|
|
1467
|
+
});
|
|
1468
|
+
ticking = true;
|
|
1469
|
+
}
|
|
1497
1470
|
};
|
|
1498
1471
|
|
|
1499
1472
|
if (scrollTarget) {
|
|
1500
|
-
scrollTarget.addEventListener('scroll',
|
|
1473
|
+
scrollTarget.addEventListener('scroll', handleScroll, { passive: true });
|
|
1501
1474
|
updateStickyState();
|
|
1502
|
-
return () => scrollTarget.removeEventListener('scroll',
|
|
1475
|
+
return () => scrollTarget.removeEventListener('scroll', handleScroll);
|
|
1503
1476
|
}
|
|
1504
1477
|
return undefined;
|
|
1505
|
-
}, [selectedDate, selectedAvailability, useWindowScroll, flowUi?.itineraryStickyTopOffsetPx
|
|
1478
|
+
}, [selectedDate, selectedAvailability, useWindowScroll, flowUi?.itineraryStickyTopOffsetPx]); // Re-check when itinerary / scroll mode / host chrome changes
|
|
1506
1479
|
|
|
1507
1480
|
// Find the earliest availability date - memoize with a stable reference
|
|
1508
1481
|
// Only recalculate if we don't have a cached value or if the new earliest is actually earlier
|
|
@@ -166,36 +166,8 @@ export function ItineraryBox({
|
|
|
166
166
|
const handlePickupLocationClick = () => {
|
|
167
167
|
const pickupSection = document.getElementById('pickup-location-section');
|
|
168
168
|
if (!pickupSection) return;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
let parent = node.parentElement;
|
|
172
|
-
while (parent) {
|
|
173
|
-
const { overflowY } = getComputedStyle(parent);
|
|
174
|
-
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') return parent;
|
|
175
|
-
parent = parent.parentElement;
|
|
176
|
-
}
|
|
177
|
-
return null;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const scrollParent = useWindowScroll ? null : findScrollParent(pickupSection);
|
|
181
|
-
const itineraryBox = document.querySelector('[class*="sticky top-"]');
|
|
182
|
-
const itineraryHeight = itineraryBox?.getBoundingClientRect().height ?? 0;
|
|
183
|
-
// Extra offset so sticky header doesn't block the pickup section (mobile needs more clearance)
|
|
184
|
-
const STICKY_HEADER_CLEARANCE = isMobile ? 280 : 270;
|
|
185
|
-
const targetOffsetFromTop = itineraryHeight + 16 + STICKY_HEADER_CLEARANCE;
|
|
186
|
-
|
|
187
|
-
if (scrollParent) {
|
|
188
|
-
const elementPosition = pickupSection.getBoundingClientRect().top;
|
|
189
|
-
const scrollDelta = elementPosition - targetOffsetFromTop;
|
|
190
|
-
scrollParent.scrollTo({
|
|
191
|
-
top: Math.max(0, scrollParent.scrollTop + scrollDelta),
|
|
192
|
-
behavior: 'smooth',
|
|
193
|
-
});
|
|
194
|
-
} else if (typeof window !== 'undefined') {
|
|
195
|
-
const elementPosition = pickupSection.getBoundingClientRect().top + window.scrollY;
|
|
196
|
-
const scrollTop = Math.max(0, elementPosition - targetOffsetFromTop);
|
|
197
|
-
window.scrollTo({ top: scrollTop, behavior: 'smooth' });
|
|
198
|
-
}
|
|
169
|
+
// Let browser handle the active scroll container (window or nested dialog/content area).
|
|
170
|
+
pickupSection.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
|
|
199
171
|
};
|
|
200
172
|
|
|
201
173
|
const getDisplayLabel = (label: string): string => {
|