Khunndev Cursor commited on
Commit
bdf846b
·
1 Parent(s): 86defa3

Hide circle number labels during intro animation until dock appears.

Browse files
frontend/src/components/ResultCanvas.tsx CHANGED
@@ -218,6 +218,8 @@ interface Props {
218
  displayBounds?: { w: number; h: number } | null
219
  /** When false (default), circles render immediately with no count-up animation. */
220
  animate?: boolean
 
 
221
  onUpdate: (dets: Detection[]) => void
222
  onCanvasReady?: (canvas: HTMLCanvasElement | null) => void
223
  onAnimationComplete?: () => void
@@ -233,6 +235,7 @@ export function ResultCanvas({
233
  selectedGroupId,
234
  displayBounds,
235
  animate = false,
 
236
  onUpdate,
237
  onCanvasReady,
238
  onAnimationComplete,
@@ -323,7 +326,6 @@ export function ResultCanvas({
323
  const { staggerMs, durationMs } = computeStagger(detections.length)
324
  const totalMs = (sorted.length - 1) * staggerMs + durationMs
325
  const dense = detections.length > 300
326
- const showLabels = detections.length <= 3000
327
  // minimum circle radius expressed in CSS pixels → converted to natural px
328
  const minR = (dense ? 5 : 7) / displayPx
329
 
@@ -356,7 +358,7 @@ export function ResultCanvas({
356
  const cy = d.ymin + ph / 2
357
  const radius = fitRadius(pw, ph, minR)
358
 
359
- drawCircle(ctx!, cx, cy, radius, rgb, progress, String(label), showLabels, displayPx)
360
  visibleCount++
361
  })
362
 
@@ -380,7 +382,7 @@ export function ResultCanvas({
380
  const cx = d.xmin + pw / 2
381
  const cy = d.ymin + ph / 2
382
  const radius = fitRadius(pw, ph, minR)
383
- drawCircle(ctx!, cx, cy, radius, rgb, 1, String(label), showLabels, displayPx)
384
  })
385
  if (countDisplayRef?.current) {
386
  countDisplayRef.current.textContent = String(detections.length)
@@ -448,7 +450,7 @@ export function ResultCanvas({
448
  ctx.drawImage(image, 0, 0, natW, natH)
449
 
450
  const dense = detections.length > 300
451
- const showLabels = detections.length <= 3000
452
  const minR = (dense ? 5 : 7) / displayPx
453
 
454
  const labels = spatialLabelMap(detections)
@@ -477,7 +479,7 @@ export function ResultCanvas({
477
  ctx.strokeRect(area.x1, area.y1, area.x2 - area.x1, area.y2 - area.y1)
478
  ctx.restore()
479
  }
480
- }, [animating, image, detections, groups, displayBounds])
481
 
482
  // -------------------------------------------------------------------------
483
  // direct canvas redraw — does NOT go through React state / onUpdate
@@ -496,7 +498,7 @@ export function ResultCanvas({
496
  const parentW = canvas.parentElement?.clientWidth ?? natW
497
  const { displayPx } = computeFitSize(natW, natH, displayBounds ?? null, parentW)
498
  const dense = detections.length > 300
499
- const showLabels = detections.length <= 3000
500
  const minR = (dense ? 5 : 7) / displayPx
501
 
502
  ctx.setTransform(rs, 0, 0, rs, 0, 0)
 
218
  displayBounds?: { w: number; h: number } | null
219
  /** When false (default), circles render immediately with no count-up animation. */
220
  animate?: boolean
221
+ /** Number labels inside circles — hide during intro animation, show on results dock. */
222
+ showCircleLabels?: boolean
223
  onUpdate: (dets: Detection[]) => void
224
  onCanvasReady?: (canvas: HTMLCanvasElement | null) => void
225
  onAnimationComplete?: () => void
 
235
  selectedGroupId,
236
  displayBounds,
237
  animate = false,
238
+ showCircleLabels = true,
239
  onUpdate,
240
  onCanvasReady,
241
  onAnimationComplete,
 
326
  const { staggerMs, durationMs } = computeStagger(detections.length)
327
  const totalMs = (sorted.length - 1) * staggerMs + durationMs
328
  const dense = detections.length > 300
 
329
  // minimum circle radius expressed in CSS pixels → converted to natural px
330
  const minR = (dense ? 5 : 7) / displayPx
331
 
 
358
  const cy = d.ymin + ph / 2
359
  const radius = fitRadius(pw, ph, minR)
360
 
361
+ drawCircle(ctx!, cx, cy, radius, rgb, progress, String(label), false, displayPx)
362
  visibleCount++
363
  })
364
 
 
382
  const cx = d.xmin + pw / 2
383
  const cy = d.ymin + ph / 2
384
  const radius = fitRadius(pw, ph, minR)
385
+ drawCircle(ctx!, cx, cy, radius, rgb, 1, String(label), false, displayPx)
386
  })
387
  if (countDisplayRef?.current) {
388
  countDisplayRef.current.textContent = String(detections.length)
 
450
  ctx.drawImage(image, 0, 0, natW, natH)
451
 
452
  const dense = detections.length > 300
453
+ const showLabels = showCircleLabels && detections.length <= 3000
454
  const minR = (dense ? 5 : 7) / displayPx
455
 
456
  const labels = spatialLabelMap(detections)
 
479
  ctx.strokeRect(area.x1, area.y1, area.x2 - area.x1, area.y2 - area.y1)
480
  ctx.restore()
481
  }
482
+ }, [animating, image, detections, groups, displayBounds, showCircleLabels])
483
 
484
  // -------------------------------------------------------------------------
485
  // direct canvas redraw — does NOT go through React state / onUpdate
 
498
  const parentW = canvas.parentElement?.clientWidth ?? natW
499
  const { displayPx } = computeFitSize(natW, natH, displayBounds ?? null, parentW)
500
  const dense = detections.length > 300
501
+ const showLabels = showCircleLabels && detections.length <= 3000
502
  const minR = (dense ? 5 : 7) / displayPx
503
 
504
  ctx.setTransform(rs, 0, 0, rs, 0, 0)
frontend/src/components/StepResults.tsx CHANGED
@@ -76,6 +76,7 @@ export function StepResults({
76
  tool={tool}
77
  selectedGroupId={selectedGroupId}
78
  animate
 
79
  displayBounds={animDone ? viewportSize : null}
80
  onUpdate={onUpdate}
81
  onCanvasReady={(c) => { canvasRef.current = c }}
 
76
  tool={tool}
77
  selectedGroupId={selectedGroupId}
78
  animate
79
+ showCircleLabels={animDone}
80
  displayBounds={animDone ? viewportSize : null}
81
  onUpdate={onUpdate}
82
  onCanvasReady={(c) => { canvasRef.current = c }}