X-Git-Url: https://git.r.bdr.sh/rbdr/canvas/blobdiff_plain/c30e688113e317ff6aca8a63f16b202cbfff3820..e4e4b5202bf0039127f591941fddc1ff5ca09897:/src/lib/components/sensor.svelte

diff --git a/src/lib/components/sensor.svelte b/src/lib/components/sensor.svelte
index e98b740..b6d38d8 100644
--- a/src/lib/components/sensor.svelte
+++ b/src/lib/components/sensor.svelte
@@ -1,11 +1,10 @@
 <script>
-  import { browser } from '$app/env';
+  import { browser } from '$app/environment';
   import { maxSize } from '$lib/config';
+  import { modulo } from '$lib/math';
+  import { canvas } from '$lib/stores/canvas';
   import { sensor } from '$lib/stores/widgets';
 
-  export let x;
-  export let y;
-
   const kSensorSize = 2;
 
   let left;
@@ -23,10 +22,10 @@
 
   $: {
     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;
+      left = modulo($canvas.x - window.screen.width * kSensorSize, maxSize);
+      top = modulo($canvas.y - window.screen.height * kSensorSize, maxSize);
+      right = left + 2 * window.screen.width * kSensorSize;
+      bottom = top + 2 * window.screen.height * kSensorSize;
 
       fetchItems(left, top, right, bottom);
     }
