Files
units-ui/components
Sebastian Krüger f214ddf0ba fix: history only saves on drag end + throttle drag updates
Fixed two critical issues with draggable bars:

1. History now only saves on drag end (not during dragging):
   - Added isDragging state to MainConverter
   - onValueChange callback now accepts dragging boolean parameter
   - History useEffect skips saving when isDragging is true
   - On mouseup/touchend, call onValueChange with dragging=false to trigger save
   - Prevents hundreds of history entries from a single drag

2. Throttled drag updates for better performance:
   - Added lastUpdateTime ref to track update frequency
   - Limited updates to 60fps (every 16ms)
   - Prevents React from being overwhelmed with rapid state updates
   - Smoother, more responsive dragging experience

How it works:
- During drag: onValueChange(value, unit, true) → isDragging=true → history skips
- On drag end: onValueChange(value, unit, false) → isDragging=false → history saves
- Drag move: throttled to max 60 updates per second

This should make bars update smoothly during drag and history
clean with only one entry per drag operation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:54:05 +01:00
..