diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 107de36d..a62a5396 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -65,6 +65,7 @@ const ae_app_local_data_defaults: key_val = { theme_mode: 'light', theme_name: 'nouveau', // wintry iframe: false, + browser_type: null, // Safari needs help with scrolling correctly in iframes. title: `OSIT's Æ`, // - Dev SvelteKit`, // Æ debug_menu: false, // Flag show debug menu. diff --git a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_li.svelte b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_li.svelte index 780da8e8..1e31eb9f 100644 --- a/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_li.svelte +++ b/src/routes/idaa/(idaa)/recovery_meetings/ae_idaa_comp__event_obj_li.svelte @@ -173,6 +173,11 @@ function add_activity_log( let message = {'event_id': idaa_event_obj?.event_id}; window.parent.postMessage(message, "*"); + if ($ae_loc?.iframe && $ae_loc.browser_type == 'safari') { + console.log('In Safari iframe, sending message to parent window to scroll to top as well'); + window.parent.postMessage({'scroll_to': 0}, "*"); // This should be in pixels + } + // $idaa_sess.recovery_meetings.show_main__options = true; // $idaa_sess.recovery_meetings.show_list__event_obj_li = true; $idaa_trig.event_id = true; diff --git a/src/routes/idaa/+layout.svelte b/src/routes/idaa/+layout.svelte index 962f26bb..8223dc69 100644 --- a/src/routes/idaa/+layout.svelte +++ b/src/routes/idaa/+layout.svelte @@ -172,11 +172,11 @@ $effect(() => { // console.log(`idaa_root_layout.svelte: data:`, data); // } - // // If the browser is Safari, we need to handle the scroll differently - // if (is_safari) { - // console.log('Safari detected, using special scroll handling'); - // // Add any Safari-specific logic here if needed - // } + // If the browser is Safari, we need to handle the scroll differently + if (is_safari) { + console.log('Safari detected, using special scroll handling'); + $ae_loc.browser_type = 'safari'; + } // // Initial scroll position // scroll_y = scroll_container().scrollTop; @@ -373,10 +373,14 @@ $effect(() => { } // var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); if (is_safari) { - console.log('Safari detected, not using smooth scroll to top'); + console.log('Safari detected, not using smooth scroll to top.'); document.getElementById('ae_idaa')?.scrollTo(0, 0); - window.parent.postMessage({'scroll_to': 0}, "*"); // This should be in pixels + if ($ae_loc?.iframe) { + // If in iframe, we need to send a message to the parent window to scroll to top + console.log('In Safari iframe, sending message to parent window to scroll to top as well'); + window.parent.postMessage({'scroll_to': 0}, "*"); // This should be in pixels + } } else { console.log('Not Safari, using smooth scroll to top'); document.getElementById('ae_idaa')?.scrollTo({