/** * Sticky-header helpers (MSEP-11). Pure logic kept separate from the DOM * wiring in CalendarManager so it is unit-testable. */ /** WP admin bar offset: 32px desktop, 46px on small screens, 0 when absent. */ export function adminBarOffset(hasAdminBar: boolean, viewportWidth: number): number { if (!hasAdminBar) { return 0; } return viewportWidth > 782 ? 32 : 46; } /** * The header sticks while the wrapper's top has scrolled past the viewport * top (minus the admin-bar offset) AND enough of the wrapper is still * visible that a stuck header doesn't cover the last rows pointlessly. */ export function shouldStickHeader( wrapperTop: number, wrapperBottom: number, headerHeight: number, offset: number ): boolean { return wrapperTop < offset && wrapperBottom > offset + headerHeight + 60; }