svelte-adapter-uws 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/cursor/client.js +12 -4
package/package.json
CHANGED
package/plugins/cursor/client.js
CHANGED
|
@@ -97,7 +97,7 @@ export function cursor(topic, options) {
|
|
|
97
97
|
targets.delete(key);
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
|
-
entry.data = { ...entry.data, x: entry.data.x + dx * 0.
|
|
100
|
+
entry.data = { ...entry.data, x: entry.data.x + dx * 0.5, y: entry.data.y + dy * 0.5 };
|
|
101
101
|
changed = true;
|
|
102
102
|
}
|
|
103
103
|
if (changed) output.set(new Map(cursorMap));
|
|
@@ -131,13 +131,21 @@ export function cursor(topic, options) {
|
|
|
131
131
|
const { key, user, data } = event.data;
|
|
132
132
|
timestamps.set(key, Date.now());
|
|
133
133
|
if (interpolate && typeof data?.x === 'number' && typeof data?.y === 'number') {
|
|
134
|
-
|
|
134
|
+
const existing = cursorMap.get(key);
|
|
135
|
+
if (!existing) {
|
|
135
136
|
cursorMap.set(key, { user, data });
|
|
136
|
-
output.set(new Map(cursorMap));
|
|
137
137
|
} else {
|
|
138
|
-
|
|
138
|
+
const dx = data.x - existing.data.x;
|
|
139
|
+
const dy = data.y - existing.data.y;
|
|
140
|
+
existing.user = user;
|
|
141
|
+
existing.data = {
|
|
142
|
+
...existing.data,
|
|
143
|
+
x: existing.data.x + dx * 0.5,
|
|
144
|
+
y: existing.data.y + dy * 0.5
|
|
145
|
+
};
|
|
139
146
|
}
|
|
140
147
|
targets.set(key, { x: data.x, y: data.y });
|
|
148
|
+
output.set(new Map(cursorMap));
|
|
141
149
|
if (rafId === null) rafId = requestAnimationFrame(tick);
|
|
142
150
|
} else {
|
|
143
151
|
cursorMap.set(key, { user, data });
|