From e4e4b5202bf0039127f591941fddc1ff5ca09897 Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Tue, 24 Jan 2023 13:07:20 +0100
Subject: Update project, improve sensor/render logic

---
 src/lib/components/sensor.svelte | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

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

diff --git a/src/lib/components/sensor.svelte b/src/lib/components/sensor.svelte
index 3b7dfc2..b6d38d8 100644
--- a/src/lib/components/sensor.svelte
+++ b/src/lib/components/sensor.svelte
@@ -1,6 +1,7 @@
 <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';
 
@@ -21,10 +22,10 @@
 
   $: {
     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;
+      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);
     }
-- 
cgit 

