Smooth phone page swipes
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s

- Keep the page rail on its own compositor layer for the whole session
  instead of promoting it at every drag start
- Write the drag transform directly in touchmove rather than a later rAF
- Carry the release velocity into the settle animation (160-340ms) so
  flicks neither brake nor lurch; covered by a unit test
- Render the page change as a transition so it cannot delay the settle
- Pause bubble physics and canvas drawing while the pager is moving

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-22 11:06:22 -07:00
parent c3b9376508
commit bb0bc430aa
6 changed files with 103 additions and 40 deletions

View file

@ -7,3 +7,17 @@ export function swipeStep(dx, dy, elapsed, width) {
const flick = distance >= 36 && distance / Math.max(1, elapsed) >= 0.5;
return deliberate || flick ? (dx < 0 ? 1 : -1) : 0;
}
// The settle curve's initial slope (y1 / x1 of the cubic-bezier) lets a
// released swipe continue at the finger's speed instead of braking or lurching.
export const SETTLE_EASING = "cubic-bezier(0.25, 0.8, 0.25, 1)";
const SETTLE_SLOPE = 0.8 / 0.25;
// Distance and velocity share a sign convention: px, and px/ms toward "to".
export function settleDuration(distance, width, velocity = 0) {
const remaining = Math.abs(distance);
const base = Math.min(340, Math.max(220, (remaining / Math.max(1, width)) * 340));
// Only a release moving toward the destination carries its momentum.
if (!velocity || Math.sign(velocity) !== Math.sign(distance)) return base;
return Math.min(base, Math.max(160, (SETTLE_SLOPE * remaining) / Math.abs(velocity)));
}