]>
Commit | Line | Data |
---|---|---|
1 | <script> | |
2 | import { browser } from '$app/env'; | |
3 | import { maxSize } from '$lib/config'; | |
4 | import { canvas } from '$lib/stores/canvas'; | |
5 | import { sensor } from '$lib/stores/widgets'; | |
6 | ||
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(() => { | |
18 | sensor.set({ left, top, right, bottom }); | |
19 | }, 50); | |
20 | } | |
21 | ||
22 | $: { | |
23 | if (browser) { | |
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; | |
28 | ||
29 | fetchItems(left, top, right, bottom); | |
30 | } | |
31 | } | |
32 | ||
33 | </script> |