Is there any way to know the progress of the current depth?
For example, If we go from 0 to 1, 0.1, 0.2, 0.3, ..., 1
If we go from 1 to 2, 1.1, 1.2, 1.3, ..., 2
If we go from 2 to 1 again, 1.9, 1.8, 1.7, ..., 1
Is there any way to get this?
-under is my current codes-
import React from "react"
import { SharedValue } from "react-native-reanimated"
import { CardStyleInterpolators, StackCardInterpolationProps } from '@react-navigation/stack';
import { createContextHook } from "../provider/provider"
import { _DEFAULT_SCREEN_OPTION } from "../util/stack";
interface ProgressContextProps {
progress: SharedValue<number>
}
const ProgressContext = React.createContext<ProgressContextProps|undefined>(undefined)
export const useProgress = () => createContextHook(ProgressContext, 'ProgressContext')
export const createCardStyleProgressInterpolator = ({ progress }: ProgressContextProps) => {
return ({
current,
next,
layouts,
closing,
index,
swiping,
inverted,
insets
}: StackCardInterpolationProps) => {
const cp = current.progress;
cp.addListener(({ value }) => {
'worklet';
if (value === 1) {
if (progress.value == 0 /* || progressValue.value >= 0.99 */) {
progress.value = index > 0 ? 1 : 0
}
} else {
progress.value = value;
}
});
return CardStyleInterpolators.forHorizontalIOS({
current,
next,
layouts,
closing,
index,
swiping,
inverted,
insets
});
};
};
export default ProgressContext