2024-06-08 22:11:27 +00:00
|
|
|
import { writable } from 'svelte/store';
|
|
|
|
|
2024-06-08 22:34:10 +00:00
|
|
|
// Check if window is available
|
|
|
|
let initialWidth: number = 0;
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
initialWidth = window.innerWidth;
|
|
|
|
}
|
|
|
|
|
2024-06-08 22:11:27 +00:00
|
|
|
// Create a writable store to track screen size
|
2024-06-08 22:34:10 +00:00
|
|
|
export const screenSize = writable<number>(initialWidth);
|
2024-06-08 22:11:27 +00:00
|
|
|
|
|
|
|
// Function to update the screen size
|
2024-06-08 22:34:10 +00:00
|
|
|
export const updateScreenSize = (): void => {
|
|
|
|
// Check if window is available before setting the screen size
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
screenSize.set(window.innerWidth);
|
|
|
|
}
|
2024-06-08 22:11:27 +00:00
|
|
|
};
|