From 2df937df1372359babd123d1361e702a1a4b8168 Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Tue, 5 Jul 2022 23:34:03 +0200
Subject: Create the sensor, move values to config

---
 src/lib/components/sensor.svelte | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'src/lib/components/sensor.svelte')

diff --git a/src/lib/components/sensor.svelte b/src/lib/components/sensor.svelte
index e69de29..da968a3 100644
--- a/src/lib/components/sensor.svelte
+++ b/src/lib/components/sensor.svelte
@@ -0,0 +1,34 @@
+<script>
+  import { browser } from '$app/env';
+  import { maxSize } from '$lib/config';
+
+  export let x;
+  export let y;
+
+  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(() => {
+      console.log('fetching', left, top, right, bottom);
+		}, 50);
+  }
+
+  $: {
+    if (browser) {
+      left = x - window.screen.width * kSensorSize;
+      top = y - window.screen.height * kSensorSize;
+      right = x + window.screen.width * kSensorSize;
+      bottom = y + window.screen.height * kSensorSize;
+
+      fetchItems(left, top, right, bottom);
+    }
+  }
+
+</script>
-- 
cgit 

