fix: improve zoom easing to threshold by deferring capping
**Problem:** The spring animation was easing slowly to the capped zoom value, taking many seconds to reach the 20 px/px threshold. This made the precision mode notices appear to activate very slowly. **Solution:** - Let spring animate to full target zoom (uncapped) - Defer zoom capping until viewBox calculation (where zoom is used) - Spring reaches threshold quickly, then "pauses" waiting for precision mode - When precision mode activates, spring continues from threshold to final target **Result:** - Fast animation to precision mode threshold - Visual effects (grid, scrim, dimming) appear quickly at threshold - Smooth transition through threshold when precision mode activates - No slow easing toward capped value **Technical details:** - Removed capping from setTargetZoom() call - Added effectiveZoom calculation in viewBox render function - effectiveZoom = min(zoom, maxZoom) when not in pointer lock - effectiveZoom = zoom when in pointer lock (no cap) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5d2cbfd432
commit
b355a3fc8f
|
|
@ -1368,10 +1368,8 @@ export function MapRenderer({
|
|||
)
|
||||
}
|
||||
|
||||
// Note: We DO NOT cap adaptiveZoom here before setting targetZoom
|
||||
// Instead, we let the spring animate toward the full target zoom
|
||||
// and apply the cap when READING the zoom value in the viewBox calculation
|
||||
// This creates a "pause" effect at the threshold rather than slow easing
|
||||
// Don't cap the target zoom - let the spring animate to full target
|
||||
// The capping will happen in the viewBox calculation where zoom is actually used
|
||||
setTargetZoom(adaptiveZoom)
|
||||
setShowMagnifier(true)
|
||||
setTargetOpacity(1)
|
||||
|
|
@ -1854,10 +1852,10 @@ export function MapRenderer({
|
|||
const cursorSvgX = (cursorPosition.x - svgOffsetX) * scaleX + viewBoxX
|
||||
const cursorSvgY = (cursorPosition.y - svgOffsetY) * scaleY + viewBoxY
|
||||
|
||||
// Apply zoom cap when not in precision mode
|
||||
// This creates a "pause" at the threshold while the spring continues to animate toward target
|
||||
// Cap zoom if not in pointer lock mode to prevent excessive screen pixel ratios
|
||||
// This creates a "pause" at the threshold while the spring continues to its target
|
||||
let effectiveZoom = zoom
|
||||
if (!pointerLocked && containerRef.current) {
|
||||
if (!pointerLocked) {
|
||||
const magnifierWidth = containerRect.width * 0.5
|
||||
// Calculate what the screen pixel ratio would be at this zoom
|
||||
const magnifiedViewBoxWidth = viewBoxWidth / zoom
|
||||
|
|
@ -1868,12 +1866,13 @@ export function MapRenderer({
|
|||
|
||||
// If it exceeds threshold, cap the zoom to stay at threshold
|
||||
if (screenPixelRatio > PRECISION_MODE_THRESHOLD) {
|
||||
// Solve for max zoom: ratio = zoom * (magnifierWidth / mainMapWidth)
|
||||
const maxZoom = PRECISION_MODE_THRESHOLD / (magnifierWidth / svgRect.width)
|
||||
effectiveZoom = Math.min(zoom, maxZoom)
|
||||
}
|
||||
}
|
||||
|
||||
// Magnified view: adaptive zoom (using animated value, capped if needed)
|
||||
// Magnified view: adaptive zoom (using capped value)
|
||||
const magnifiedWidth = viewBoxWidth / effectiveZoom
|
||||
const magnifiedHeight = viewBoxHeight / effectiveZoom
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue