From 473f18d510ea3db4f0679e5a9661f02f6e0b8659 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 13 Aug 2021 11:34:11 +0100 Subject: [PATCH] Tidy up device bindings provider --- .../src/components/DeviceBindingsProvider.svelte | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/client/src/components/DeviceBindingsProvider.svelte b/packages/client/src/components/DeviceBindingsProvider.svelte index 81a0f45d02..864068cd17 100644 --- a/packages/client/src/components/DeviceBindingsProvider.svelte +++ b/packages/client/src/components/DeviceBindingsProvider.svelte @@ -2,21 +2,19 @@ import Provider from "./Provider.svelte" import { onMount } from "svelte" + let width = window.innerWidth const tabletBreakpoint = 768 const desktopBreakpoint = 1280 - - let screenWidth = window.innerWidth const resizeObserver = new ResizeObserver(entries => { if (entries?.[0]) { - screenWidth = entries[0].contentRect?.width + width = entries[0].contentRect?.width } }) - $: mobile = screenWidth && screenWidth < tabletBreakpoint - $: tablet = - screenWidth && - screenWidth >= tabletBreakpoint && - screenWidth < desktopBreakpoint - $: data = { mobile, tablet } + + $: data = { + mobile: width && width < tabletBreakpoint, + tablet: width && width >= tabletBreakpoint && width < desktopBreakpoint, + } onMount(() => { const doc = document.documentElement