mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-20 04:30:54 +02:00
fix now playing swipe softlock
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user