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