Fix slider interference with scroll gestures on touch devices across all diagrams#82
Conversation
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
…fying Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
|
@copilot if this is the correct diagnosis of the problem, why does it go back to the proper velocity setting after a moment? |
Great question! The "snap back" happens because of the feedback loop between the slider and the diagram controller. What was happening:
So the "snap back" was the controller resetting the slider to the correct value after the spurious input event had already updated the display. The fix prevents the spurious input events from firing during scrolling, eliminating both the initial shift and the snap back. Fixed in commit ae3bdd1. |
|
@copilot does this bug affect other tabs, like the spacetime interval tab. If so fix it |
… diagram sliders Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Yes, the bug affected other tabs with D3-created sliders. Fixed all affected sliders: ✅ Spacetime Interval tab - Position slider (animation control) Applied the same touch event handling to all three diagrams. All sliders now properly distinguish between vertical scrolling and horizontal slider interaction. Fixed in commit 9211b0b. |
…gging Extract duplicated touch gesture detection logic from three diagram files into minkowski-core.ts, creating attachSliderTouchHandlers() utility function. This eliminates ~160 lines of duplication and provides a single source of truth for distinguishing scroll from slider gestures. Add comprehensive error logging for production debugging: - console.error when TouchEvent.touches is null/undefined (browser bugs) - console.warn when touch data is lost mid-gesture (system interruptions) - console.debug when gestures are cancelled (OS events like calls) All logging includes browser UserAgent for device-specific debugging, making it possible to diagnose "doesn't work on my iPad" issues with actionable data instead of guesswork. Net impact: -69 lines, improved maintainability, production-ready error visibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add 22 new tests for touch gesture detection covering all critical gaps identified in code review: Gesture Direction Detection (6 tests): - Horizontal swipes trigger slider interaction (preventDefault) - Vertical swipes allow page scrolling (no preventDefault) - Movement below 10px threshold doesn't trigger gesture classification - Threshold boundary testing (9px ignored, 11px detected) - Diagonal movement uses dominant axis for classification Null Safety (4 tests): - Null TouchEvent.touches logs error and fails safely - Empty touches array logs error - Touch data loss mid-gesture logs warning and deactivates - Inactive sliders ignore spurious touchmove events State Management (6 tests): - Touch lifecycle (touchstart/touchmove/touchend/touchcancel) - Start coordinate capture for delta calculations - Rapid touch cycles handled correctly - Independent state across multiple sliders Integration (3 tests): - CSS touch-action property verification - D3 selection method chaining - Event handler composition All tests use realistic mock TouchEvent objects and verify both behavior and logging output. Covers the core bug fix logic that distinguishes scroll from slider gestures on touch devices. Test count: 433 total (up from 411) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
On touch devices, scrolling the page caused D3-created sliders in Minkowski diagrams to briefly trigger, shifting rendered values before snapping back to correct values.
Root Cause
D3-created sliders in multiple diagrams captured touch events during vertical scrolling, generating spurious input events.
Affected Components Fixed
Twins Paradox Tab (
minkowski-twins.ts)Spacetime Interval Tab (
minkowski.ts)Simultaneity Diagram (
simultaneity.ts)Changes
Touch Event Filtering
preventDefault()for horizontal gestures (slider interaction)CSS Properties
touch-action: pan-yon slider containers (allows vertical scrolling)touch-action: noneon slider inputs (enables custom gesture handling)Safety
TouchEvent.touchesedge casesTesting
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.