@ticketboothapp/booking 1.2.44 → 1.2.45
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
|
@@ -1405,51 +1405,77 @@ export function BookingFlow({
|
|
|
1405
1405
|
};
|
|
1406
1406
|
}, [showTooltip]);
|
|
1407
1407
|
|
|
1408
|
-
// Detect when itinerary box becomes sticky
|
|
1409
|
-
//
|
|
1410
|
-
//
|
|
1408
|
+
// Detect when itinerary box becomes sticky
|
|
1409
|
+
// In viavia the scroll usually happens inside the dialog content div, not window.
|
|
1410
|
+
// On full-page partner layouts, we instead listen to window scroll (useWindowScroll = true).
|
|
1411
|
+
const lastStickyChangeRef = useRef<number>(0);
|
|
1411
1412
|
useEffect(() => {
|
|
1412
1413
|
const el = itineraryRef.current;
|
|
1413
1414
|
if (!el) return;
|
|
1414
|
-
if (typeof window === 'undefined' || !('IntersectionObserver' in window)) return;
|
|
1415
|
-
|
|
1416
|
-
const topInset = Math.max(0, flowUi?.itineraryStickyTopOffsetPx ?? 0);
|
|
1417
|
-
const sentinel = document.createElement('div');
|
|
1418
|
-
sentinel.setAttribute('data-itinerary-sticky-sentinel', 'true');
|
|
1419
|
-
sentinel.style.height = '1px';
|
|
1420
|
-
sentinel.style.margin = '0';
|
|
1421
|
-
sentinel.style.padding = '0';
|
|
1422
|
-
sentinel.style.pointerEvents = 'none';
|
|
1423
|
-
el.parentElement?.insertBefore(sentinel, el);
|
|
1424
|
-
|
|
1425
|
-
const observer = new IntersectionObserver(
|
|
1426
|
-
([entry]) => {
|
|
1427
|
-
const nextSticky = !entry.isIntersecting;
|
|
1428
|
-
if (nextSticky !== isItineraryStickyRef.current) {
|
|
1429
|
-
isItineraryStickyRef.current = nextSticky;
|
|
1430
|
-
setIsItinerarySticky(nextSticky);
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
root: null,
|
|
1435
|
-
rootMargin: `${-topInset}px 0px 0px 0px`,
|
|
1436
|
-
threshold: 0,
|
|
1437
|
-
},
|
|
1438
|
-
);
|
|
1439
1415
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1416
|
+
const findScrollParent = (node: HTMLElement): HTMLElement | null => {
|
|
1417
|
+
let parent = node.parentElement;
|
|
1418
|
+
while (parent) {
|
|
1419
|
+
const { overflowY } = getComputedStyle(parent);
|
|
1420
|
+
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') return parent;
|
|
1421
|
+
parent = parent.parentElement;
|
|
1422
|
+
}
|
|
1423
|
+
return null;
|
|
1444
1424
|
};
|
|
1445
|
-
}, [selectedDate, selectedAvailability, flowUi?.itineraryStickyTopOffsetPx]); // Re-check when itinerary changes or host top inset changes
|
|
1446
1425
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1426
|
+
const scrollParent = findScrollParent(el);
|
|
1427
|
+
const scrollTarget =
|
|
1428
|
+
useWindowScroll || !scrollParent
|
|
1429
|
+
? (typeof window !== 'undefined' ? window : null)
|
|
1430
|
+
: scrollParent;
|
|
1431
|
+
|
|
1432
|
+
let ticking = false;
|
|
1433
|
+
const COOLDOWN_MS = 600; // After a state change, ignore reverse changes for this long (covers 0.25s collapse animation + layout settle)
|
|
1434
|
+
const atTopBand = 48; // px - must scroll back up past this band to expand again (wider = less oscillation at edges)
|
|
1435
|
+
|
|
1436
|
+
const updateStickyState = () => {
|
|
1437
|
+
if (!itineraryRef.current) return;
|
|
1438
|
+
|
|
1439
|
+
const rect = itineraryRef.current.getBoundingClientRect();
|
|
1440
|
+
const currentTop = rect.top;
|
|
1441
|
+
const wasSticky = isItineraryStickyRef.current;
|
|
1442
|
+
|
|
1443
|
+
const containerTop =
|
|
1444
|
+
scrollParent && !useWindowScroll ? scrollParent.getBoundingClientRect().top : 0;
|
|
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
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
|
|
1472
|
+
if (scrollTarget) {
|
|
1473
|
+
scrollTarget.addEventListener('scroll', handleScroll, { passive: true });
|
|
1474
|
+
updateStickyState();
|
|
1475
|
+
return () => scrollTarget.removeEventListener('scroll', handleScroll);
|
|
1476
|
+
}
|
|
1477
|
+
return undefined;
|
|
1478
|
+
}, [selectedDate, selectedAvailability, useWindowScroll, flowUi?.itineraryStickyTopOffsetPx]); // Re-check when itinerary / scroll mode / host chrome changes
|
|
1453
1479
|
|
|
1454
1480
|
// Find the earliest availability date - memoize with a stable reference
|
|
1455
1481
|
// Only recalculate if we don't have a cached value or if the new earliest is actually earlier
|
|
@@ -35,6 +35,4 @@ export const PARTNER_EMBEDDED_BOOKING_FLOW_UI_BASE: BookingFlowUiOptions = {
|
|
|
35
35
|
showTourDescription: false,
|
|
36
36
|
autoSelectFirstAvailableDate: true,
|
|
37
37
|
autoSelectFirstHighlightedPickup: true,
|
|
38
|
-
// TicketBooth dashboard has sticky header/tabs; keep sticky itinerary visibly below.
|
|
39
|
-
itineraryStickyTopOffsetPx: 88,
|
|
40
38
|
};
|