mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Check for window to exist
This commit is contained in:
1 parent
83f081aafc
commit
e71fc08b2f
1 file changed
+8
-2
@@ -3,11 +3,17 @@ import { writable } from 'svelte/store';
|
||||
const isSmallViewport = writable(false);
|
||||
|
||||
function updateViewport() {
|
||||
isSmallViewport.set(window.matchMedia('(max-width: 768px)').matches);
|
||||
if (typeof window !== 'undefined') {
|
||||
isSmallViewport.set(
|
||||
typeof window !== 'undefined' ? window.matchMedia('(max-width: 768px)').matches : false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize on import
|
||||
updateViewport();
|
||||
window.addEventListener('resize', updateViewport);
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('resize', updateViewport);
|
||||
}
|
||||
|
||||
export { isSmallViewport };
|
||||
Reference in new issue
Block a user