soroban-abacus-flashcards/apps
Thomas Hallock a7fa858a29 fix(know-your-world): fix pointer lock escape for all edges and add smooth release animation
**Problem:**
- Left/right edge squish-through escape wasn't working when SVG didn't fill container width
- Cursor would jump when releasing pointer lock (managed cursor position ≠ real cursor position)

**Root Cause:**
- Boundary detection used container rect instead of SVG rect
- SVG may be smaller than container due to aspect ratio constraints
- No animation back to initial capture position before releasing pointer lock

**Solution:**

1. **Use SVG boundaries for edge detection:**
   - Calculate SVG offset within container (lines 796-797)
   - Measure distances from SVG edges, not container edges (lines 806-809)
   - Use SVG bounds for dampened distance checks (lines 831-834)
   - Clamp cursor to SVG bounds (lines 914-915)
   - Added debug logging showing SVG size/offset (lines 842-843)

2. **Smooth release animation:**
   - Store initial cursor position when pointer lock acquired (line 185, 244-246)
   - Track release animation state (line 192)
   - Animate cursor back to capture position before releasing (lines 890-921)
   - 200ms cubic ease-out interpolation
   - Block mouse input during animation (lines 773-774)
   - Real cursor appears at same position where user clicked - no jump!

**Result:**
- Squish-through escape works on all four edges regardless of map aspect ratio
- Seamless transition when releasing pointer lock
- Cursor smoothly returns to original position before handoff to real cursor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 21:50:13 -06:00
..
web fix(know-your-world): fix pointer lock escape for all edges and add smooth release animation 2025-11-22 21:50:13 -06:00