fix now playing swipe softlock

This commit is contained in:
Boof2015
2026-07-28 14:08:15 -04:00
parent 4c40af970b
commit f00cd0abcd
8 changed files with 328 additions and 103 deletions
@@ -6,6 +6,8 @@ const BASE_DAMPING = 28;
const MAX_DAMPING = 60;
const MIN_REMAINING_DISTANCE = 120;
const VELOCITY_TRAVEL_DAMPING = 1.35;
const DISMISS_DISTANCE = 140;
const DISMISS_VELOCITY = 1000;
interface NowPlayingDismissSpring {
velocity: number;
@@ -13,6 +15,8 @@ interface NowPlayingDismissSpring {
damping: number;
}
export type NowPlayingPanRelease = 'dismiss' | 'restore';
/**
* The overlay pan must briefly yield when its body is being replaced. Otherwise
* RNGH can cancel the old child tree after it has already written a partial
@@ -26,6 +30,41 @@ export function shouldEnableNowPlayingPan(
return playerOpen && !childSheetOpen && !bodySwitching;
}
/**
* Queue/lyrics companion rails own their scroll gestures. A non-finite boundary
* means there is no companion rail, so the whole phone player remains eligible.
*/
export function shouldStartNowPlayingPan(
panEnabled: boolean,
absoluteX: number,
companionStartX: number
): boolean {
'worklet';
if (!panEnabled) return false;
if (!Number.isFinite(companionStartX)) return true;
return Number.isFinite(absoluteX) && absoluteX < companionStartX;
}
/**
* Cancellation is authoritative even if the last event carried a large
* translation or velocity. Only a successfully ended gesture may dismiss.
*/
export function resolveNowPlayingPanRelease(
translationY: number,
velocityY: number,
success: boolean
): NowPlayingPanRelease {
'worklet';
if (!success) return 'restore';
const distance = Number.isFinite(translationY) ? Math.max(0, translationY) : 0;
const velocity = Number.isFinite(velocityY) ? Math.max(0, velocityY) : 0;
return distance > DISMISS_DISTANCE || velocity > DISMISS_VELOCITY
? 'dismiss'
: 'restore';
}
/**
* Preserve the exact release velocity, then make the spring progressively
* stronger and more damped for hard flicks so it sheds speed after handoff.