mirror of
https://github.com/AbaTekNTNU/followspot-psn.git
synced 2025-12-06 13:54:58 +00:00
Add resize reset
This commit is contained in:
@@ -14,21 +14,36 @@
|
||||
let width = $state(0);
|
||||
let height = $state(0);
|
||||
|
||||
const resize = () => {
|
||||
width = image?.getBoundingClientRect().width ?? 0;
|
||||
height = image?.getBoundingClientRect().height ?? 0;
|
||||
};
|
||||
let debounce: number | null = $state(null);
|
||||
|
||||
onMount(() => {
|
||||
const connect = () => {
|
||||
ws = new WebSocket("/ws");
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
for (const tracker of data) {
|
||||
tracker.x *= width
|
||||
tracker.y *= height
|
||||
tracker.x *= width;
|
||||
tracker.y *= height;
|
||||
}
|
||||
trackers = data;
|
||||
};
|
||||
};
|
||||
|
||||
const resize = () => {
|
||||
width = image?.getBoundingClientRect().width ?? 0;
|
||||
height = image?.getBoundingClientRect().height ?? 0;
|
||||
|
||||
if (debounce) {
|
||||
clearTimeout(debounce);
|
||||
}
|
||||
|
||||
debounce = setTimeout(() => {
|
||||
connect();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
connect();
|
||||
|
||||
width = image?.getBoundingClientRect().width ?? 0;
|
||||
height = image?.getBoundingClientRect().height ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user