]> git.r.bdr.sh - rbdr/canvas/blame - src/lib/components/sensor.svelte
Partially render the boxes
[rbdr/canvas] / src / lib / components / sensor.svelte
CommitLineData
2df937df
RBR
1<script>
2 import { browser } from '$app/env';
3 import { maxSize } from '$lib/config';
d7cea969 4 import { canvas } from '$lib/stores/canvas';
c30e6881 5 import { sensor } from '$lib/stores/widgets';
2df937df 6
2df937df
RBR
7 const kSensorSize = 2;
8
9 let left;
10 let right;
11 let top;
12 let bottom;
13
14 let timer;
15 const fetchItems = function fetchItems( left, top, right, bottom ) {
16 clearTimeout(timer);
17 timer = setTimeout(() => {
c30e6881 18 sensor.set({ left, top, right, bottom });
2df937df
RBR
19 }, 50);
20 }
21
22 $: {
23 if (browser) {
d7cea969
RBR
24 left = $canvas.x - window.screen.width * kSensorSize;
25 top = $canvas.y - window.screen.height * kSensorSize;
26 right = $canvas.x + window.screen.width * kSensorSize;
27 bottom = $canvas.y + window.screen.height * kSensorSize;
2df937df
RBR
28
29 fetchItems(left, top, right, bottom);
30 }
31 }
32
33</script>