fix: added event listener to scroll when transition ends

This commit is contained in:
Tobias Johansson
2024-11-29 15:05:38 +01:00
parent d3dad4c73d
commit 92db90502c
3 changed files with 17 additions and 58 deletions

View File

@@ -42,6 +42,16 @@ export function extractGuestFromUser(user: NonNullable<SafeUser>) {
export function navigate(step: StepEnum, searchParams: string) {
window.history.pushState({ step }, "", `${step}?${searchParams}`)
const element = document.querySelector(`[data-step='${step}']`)
const isMobile = window.matchMedia("(max-width: 768px)").matches
if (element && isMobile) {
element.addEventListener(
"transitionend",
() => element?.scrollIntoView({ behavior: "smooth" }),
{ once: true }
)
}
}
export function checkIsSameBooking(prev: BookingData, next: BookingData) {