fix(drag): Fix slow flick velocity and catch-and-release momentum#3530
fix(drag): Fix slow flick velocity and catch-and-release momentum#3530mattgperry merged 3 commits intomainfrom
Conversation
…h-and-release Fix velocity calculation for hold-then-flick gestures by skipping stale pointer-down origin points in PanSession.getVelocity(). Fix momentum resuming after catch-and-release by stopping animations on pointer down instead of pausing, and starting fresh constraint animations on release instead of resuming paused momentum. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code ReviewI've reviewed this PR and it looks like a well-thought-out fix for drag momentum issues. Here's my detailed feedback: ✅ Strengths
🔍 Potential Issues & Questions1. Edge Case in Velocity Calculation (Medium Priority)// PanSession.ts:392-398
if (
timestampedPoint === history[0] &&
history.length > 2 &&
lastPoint.timestamp - timestampedPoint.timestamp >
secondsToMilliseconds(timeDelta) * 2
) {
timestampedPoint = history[1]
}Concern: What if Suggestion: Consider checking that the distance between 2. Behavior Change in
|
… drags Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request ReviewGreat work on addressing issue #1747! This PR fixes two related drag momentum bugs with a clean, well-tested implementation. Here's my detailed review: ✅ Code Quality & ImplementationPanSession.ts velocity calculation fix (lines 385-399)
VisualElementDragControls.ts animation lifecycle fix (lines 110-114, 237-242)
🧪 Test CoverageCypress E2E tests are excellent:
Minor suggestions:
|
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request Review: Fix drag momentum velocity and catch-and-release behaviorSummaryThis PR addresses two related issues in drag gesture handling:
Code Quality & Best Practices ✅Strengths
Implementation AnalysisPanSession.ts (lines 385-399)The velocity calculation fix is elegant and well-reasoned: if (
timestampedPoint === history[0] &&
history.length > 2 &&
lastPoint.timestamp - timestampedPoint.timestamp >
secondsToMilliseconds(timeDelta) * 2
) {
timestampedPoint = history[1]
}Rationale: When a user holds down the pointer for >200ms (2x the 100ms timeDelta) before flicking, the algorithm was calculating velocity from the initial pointer-down point, resulting in artificially low velocity. Skipping to Trade-off consideration: The VisualElementDragControls.ts (lines 110-115, 237-242)The animation lifecycle changes are correct:
This prevents the problematic scenario where:
New behavior: After catch-and-release, if constraints or Test Coverage ✅Cypress E2E TestsThe two new tests in
Test quality: Both tests use realistic gesture sequences and verify observable behavior (element position) rather than internal state. The timing values (waits) are appropriate for simulating human gestures. Potential Test Improvements (minor)
Potential Issues & Concerns1. History Array Edge Cases
|
Summary
PanSession.getVelocity()when calculating velocity for hold-then-flick gestures. The pointer-down timestamp was diluting velocity over a long time gap instead of using recent movement points.pauseAnimationandgetAnimationStateprivate methods fromVisualElementDragControls.Test plan
🤖 Generated with Claude Code