fix: make progress bars initialise out of view
This commit is contained in:
@@ -20,8 +20,8 @@ export function calculateProgressTranslation(
|
|||||||
const completion = position / reference;
|
const completion = position / reference;
|
||||||
|
|
||||||
// GUARD: Check whether the calculated number is valid and not infinite
|
// GUARD: Check whether the calculated number is valid and not infinite
|
||||||
if (Number.isNaN(completion) || !Number.isFinite(completion)) {
|
if (Number.isNaN(completion) || !Number.isFinite(completion) || !width) {
|
||||||
return 0;
|
return -1_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = (1 - completion) * -1 * width;
|
const output = (1 - completion) * -1 * width;
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ function NowPlaying({ offset = 0, inset }: { offset?: number, inset?: boolean })
|
|||||||
|
|
||||||
const navigation = useNavigation<NavigationProp>();
|
const navigation = useNavigation<NavigationProp>();
|
||||||
|
|
||||||
const bufferAnimation = useRef(new Animated.Value(0));
|
const bufferAnimation = useRef(new Animated.Value(-1_000));
|
||||||
const progressAnimation = useRef(new Animated.Value(0));
|
const progressAnimation = useRef(new Animated.Value(-1_000));
|
||||||
|
|
||||||
const openNowPlayingModal = useCallback(() => {
|
const openNowPlayingModal = useCallback(() => {
|
||||||
navigation.navigate('Player');
|
navigation.navigate('Player');
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default function LyricsProgress({
|
|||||||
// Calculate the progress animation
|
// Calculate the progress animation
|
||||||
const progressAnimation = useDerivedValue(() => {
|
const progressAnimation = useDerivedValue(() => {
|
||||||
// GUARD: If the animatino is not active, hide the progress bar
|
// GUARD: If the animatino is not active, hide the progress bar
|
||||||
if (!active) return -width.value;
|
if (!active) return -1_000;
|
||||||
|
|
||||||
// Calculate how far along we are
|
// Calculate how far along we are
|
||||||
const progress = calculateProgressTranslation(position - start, end - start, width.value);
|
const progress = calculateProgressTranslation(position - start, end - start, width.value);
|
||||||
@@ -65,6 +65,8 @@ export default function LyricsProgress({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(progressAnimation.value);
|
||||||
|
|
||||||
// GUARD: Only show durations if they last for more than 5 seconds.
|
// GUARD: Only show durations if they last for more than 5 seconds.
|
||||||
if (duration < 5e7) {
|
if (duration < 5e7) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ function ProgressBar() {
|
|||||||
<ProgressTrack
|
<ProgressTrack
|
||||||
style={[
|
style={[
|
||||||
styles.themeBackground,
|
styles.themeBackground,
|
||||||
bufferStyles
|
bufferStyles,
|
||||||
]}
|
]}
|
||||||
opacity={0.15}
|
opacity={0.15}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user