feat: better colab

This commit is contained in:
2025-07-08 14:57:44 +02:00
parent e9d8a1a818
commit d5a744652d
2 changed files with 37 additions and 4 deletions

View File

@ -119,7 +119,7 @@
let socket: Socket;
let room: string;
let isStateSynced = false;
let lastMoveTime = 0;
let lastEmitTime = 0;
onMount(() => {
const urlParams = new URLSearchParams(window.location.search);
@ -291,9 +291,9 @@
card.zIndex = ++maxZIndex;
const now = Date.now();
if (now - lastMoveTime > 50) { // Throttle to 20fps
if (now - lastEmitTime > 16) { // Throttle to ~60fps
socket.emit('card-move', { room, id, x, y, zIndex: card.zIndex });
lastMoveTime = now;
lastEmitTime = now;
}
}
}
@ -431,6 +431,7 @@
}
function collectToDeck() {
if (!confirm('Are you sure you want to collect all cards to the deck?')) return;
cards.forEach((card, index) => {
card.x = deckPosition.x + index * 2;
card.y = deckPosition.y + index * 2;
@ -442,6 +443,7 @@
}
function dealCards() {
if (!confirm('Are you sure you want to deal all cards?')) return;
cards.forEach((card, index) => {
card.x = 50 + 330 + (index % 6) * 240;
card.y = 50 + Math.floor(index / 6) * 320;
@ -607,7 +609,11 @@
note.x = x;
note.y = y;
note.zIndex = ++maxZIndex;
socket.emit('sticky-note-move', { room, id, x, y, zIndex: note.zIndex });
const now = Date.now();
if (now - lastEmitTime > 16) { // Throttle to ~60fps
socket.emit('sticky-note-move', { room, id, x, y, zIndex: note.zIndex });
lastEmitTime = now;
}
}
}