]> git.r.bdr.sh - rbdr/canvas/blobdiff - src/lib/components/sensor.svelte
Update project, improve sensor/render logic
[rbdr/canvas] / src / lib / components / sensor.svelte
index 3b7dfc2724643f177dff50bc18ed73b2d6a27a44..b6d38d83cfefeecb176a36741f24fc27ddcca0f9 100644 (file)
@@ -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';
 
 
   $: {
     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);
     }