Fixed issue where bars would snap back to original position on drag release. Problem: - On mouseup/touchend, we cleared draggedPercentage immediately - Conversions hadn't updated yet (async state updates) - Bar switched from draggedPercentage to old item.percentage - Bar visually "snapped back" to original position Solution: Delay clearing drag state until conversions update - On drag end: only clear draggingUnit, keep draggedPercentage - Added useEffect that watches conversions + draggingUnit - When !draggingUnit && draggedPercentage !== null → drag just ended - This means conversions have updated, safe to clear visual state - Now clears draggedPercentage and baseConversionsRef Flow: 1. User releases mouse/touch 2. handleMouseUp/handleTouchEnd: calls onValueChange(..., false) 3. Sets draggingUnit = null (stops active drag) 4. Keeps draggedPercentage (maintains visual position) 5. MainConverter updates inputValue and selectedUnit 6. Conversions recalculate 7. useEffect detects: !draggingUnit && draggedPercentage 8. Clears draggedPercentage → bar smoothly transitions to calculated position Result: Bar stays at dragged position and smoothly settles to final value! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
12 KiB
12 KiB