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>
23 lines
1.2 KiB
JavaScript
23 lines
1.2 KiB
JavaScript
// Direction is the next tab (+1) or previous tab (-1). Vertical scrolling wins
|
|
// unless a gesture has a clear horizontal intent; small jitter never navigates.
|
|
export function swipeStep(dx, dy, elapsed, width) {
|
|
if (Math.abs(dx) < Math.abs(dy) * 1.4) return 0;
|
|
const distance = Math.abs(dx);
|
|
const deliberate = distance >= Math.min(90, Math.max(55, width * 0.18));
|
|
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)));
|
|
}
|