gabraken commited on
Commit
f5e8a90
·
1 Parent(s): 8c8d636
.gitignore CHANGED
@@ -6,4 +6,5 @@ __pycache__/
6
  **/*.pyc
7
  **/__pycache__/
8
  frontend/.svelte-kit/generated/
9
- frontend/.svelte-kit/output/
 
 
6
  **/*.pyc
7
  **/__pycache__/
8
  frontend/.svelte-kit/generated/
9
+ frontend/.svelte-kit/output/
10
+ real/
frontend/src/lib/components/Map.svelte CHANGED
@@ -175,8 +175,8 @@
175
  e.touches[0].clientY - touchState.startY
176
  ) > 6;
177
 
178
- vx = clamp(vx - dx, 0, MAP_W - vw);
179
- vy = clamp(vy - dy, 0, MAP_H - vh);
180
  touchState = { ...touchState, lastX: e.touches[0].clientX, lastY: e.touches[0].clientY, moved };
181
  }
182
  }
@@ -192,6 +192,9 @@
192
  // Mouse pan for desktop
193
  let mouseDown = false;
194
  let mouseLastX = 0, mouseLastY = 0;
 
 
 
195
 
196
  function onMouseDown(e: MouseEvent) {
197
  mouseDown = true;
@@ -204,8 +207,8 @@
204
  const rect = svgEl.getBoundingClientRect();
205
  const sx = vw / rect.width;
206
  const sy = vh / rect.height;
207
- vx = clamp(vx - (e.clientX - mouseLastX) * sx, 0, MAP_W - vw);
208
- vy = clamp(vy - (e.clientY - mouseLastY) * sy, 0, MAP_H - vh);
209
  mouseLastX = e.clientX;
210
  mouseLastY = e.clientY;
211
  }
@@ -344,6 +347,14 @@
344
  const now = performance.now();
345
  let changed = false;
346
 
 
 
 
 
 
 
 
 
347
  for (const id of Object.keys(unitRenderStates)) {
348
  const s = unitRenderStates[id];
349
  const t = Math.min((now - s.updateTime) / TICK_MS, 1);
@@ -861,7 +872,7 @@
861
  per-cell rects, works in all environments (no SVG mask url(#id) needed).
862
  Computed reactively via $: fogRects so viewport panning is always in sync. -->
863
  {#each fogRects as r}
864
- <rect x={r.x} y={r.y} width={r.w + 0.02} height={1.02} fill="rgba(0,0,0,{r.opacity})" pointer-events="none" shape-rendering="crispEdges" />
865
  {/each}
866
 
867
  <!-- Tutorial target beacon (rendered above fog so it's always visible) -->
 
175
  e.touches[0].clientY - touchState.startY
176
  ) > 6;
177
 
178
+ pendingPanDx -= dx;
179
+ pendingPanDy -= dy;
180
  touchState = { ...touchState, lastX: e.touches[0].clientX, lastY: e.touches[0].clientY, moved };
181
  }
182
  }
 
192
  // Mouse pan for desktop
193
  let mouseDown = false;
194
  let mouseLastX = 0, mouseLastY = 0;
195
+ // Pending pan deltas accumulated from input events, applied in animLoop to keep
196
+ // viewBox and sprite positions in the same RAF frame (avoids 1-frame jump).
197
+ let pendingPanDx = 0, pendingPanDy = 0;
198
 
199
  function onMouseDown(e: MouseEvent) {
200
  mouseDown = true;
 
207
  const rect = svgEl.getBoundingClientRect();
208
  const sx = vw / rect.width;
209
  const sy = vh / rect.height;
210
+ pendingPanDx -= (e.clientX - mouseLastX) * sx;
211
+ pendingPanDy -= (e.clientY - mouseLastY) * sy;
212
  mouseLastX = e.clientX;
213
  mouseLastY = e.clientY;
214
  }
 
347
  const now = performance.now();
348
  let changed = false;
349
 
350
+ // Apply accumulated pan deltas here so viewBox + sprite positions update in the same frame.
351
+ if (pendingPanDx !== 0 || pendingPanDy !== 0) {
352
+ vx = clamp(vx + pendingPanDx, 0, MAP_W - vw);
353
+ vy = clamp(vy + pendingPanDy, 0, MAP_H - vh);
354
+ pendingPanDx = 0;
355
+ pendingPanDy = 0;
356
+ }
357
+
358
  for (const id of Object.keys(unitRenderStates)) {
359
  const s = unitRenderStates[id];
360
  const t = Math.min((now - s.updateTime) / TICK_MS, 1);
 
872
  per-cell rects, works in all environments (no SVG mask url(#id) needed).
873
  Computed reactively via $: fogRects so viewport panning is always in sync. -->
874
  {#each fogRects as r}
875
+ <rect x={r.x} y={r.y} width={r.w} height={1} fill="rgba(0,0,0,{r.opacity})" pointer-events="none" shape-rendering="crispEdges" />
876
  {/each}
877
 
878
  <!-- Tutorial target beacon (rendered above fog so it's always visible) -->