]> git.r.bdr.sh - rbdr/canvas/blobdiff - src/lib/components/sensor.svelte
Render cases when the boundary crosses the viewport
[rbdr/canvas] / src / lib / components / sensor.svelte
index da968a3220432c74dc24401af9fa54d48175cd7a..3b7dfc2724643f177dff50bc18ed73b2d6a27a44 100644 (file)
@@ -1,9 +1,8 @@
 <script>
   import { browser } from '$app/env';
   import { maxSize } from '$lib/config';
 <script>
   import { browser } from '$app/env';
   import { maxSize } from '$lib/config';
-
-  export let x;
-  export let y;
+  import { canvas } from '$lib/stores/canvas';
+  import { sensor } from '$lib/stores/widgets';
 
   const kSensorSize = 2;
 
 
   const kSensorSize = 2;
 
   const fetchItems = function fetchItems( left, top, right, bottom ) {
     clearTimeout(timer);
                timer = setTimeout(() => {
   const fetchItems = function fetchItems( left, top, right, bottom ) {
     clearTimeout(timer);
                timer = setTimeout(() => {
-      console.log('fetching', left, top, right, bottom);
+      sensor.set({ left, top, right, bottom });
                }, 50);
   }
 
   $: {
     if (browser) {
                }, 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;
+      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);
     }
 
       fetchItems(left, top, right, bottom);
     }