X-Git-Url: https://git.r.bdr.sh/rbdr/canvas/blobdiff_plain/3717f7fbf9ec110b51fe002cdced5d73ebd6136b..c55cffecda48be785d89721dc8c8f04c99270b2d:/src/lib/components/sensor.svelte?ds=sidebyside

diff --git a/src/lib/components/sensor.svelte b/src/lib/components/sensor.svelte
index e69de29..3b7dfc2 100644
--- a/src/lib/components/sensor.svelte
+++ b/src/lib/components/sensor.svelte
@@ -0,0 +1,33 @@
+<script>
+  import { browser } from '$app/env';
+  import { maxSize } from '$lib/config';
+  import { canvas } from '$lib/stores/canvas';
+  import { sensor } from '$lib/stores/widgets';
+
+  const kSensorSize = 2;
+
+  let left;
+  let right;
+  let top;
+  let bottom;
+
+  let timer;
+  const fetchItems = function fetchItems( left, top, right, bottom ) {
+    clearTimeout(timer);
+		timer = setTimeout(() => {
+      sensor.set({ left, top, right, bottom });
+		}, 50);
+  }
+
+  $: {
+    if (browser) {
+      left = $canvas.x - window.screen.width * kSensorSize;
+      top = $canvas.y - window.screen.height * kSensorSize;
+      right = $canvas.x + window.screen.width * kSensorSize;
+      bottom = $canvas.y + window.screen.height * kSensorSize;
+
+      fetchItems(left, top, right, bottom);
+    }
+  }
+
+</script>
