Tweak
This commit is contained in:
+42
-61
@@ -22,72 +22,48 @@ SplashScreen.preventAutoHideAsync().catch(() => {})
|
|||||||
const AnimatedLogo = Animated.createAnimatedComponent(Logo)
|
const AnimatedLogo = Animated.createAnimatedComponent(Logo)
|
||||||
|
|
||||||
export function Splash(props: React.PropsWithChildren<Props>) {
|
export function Splash(props: React.PropsWithChildren<Props>) {
|
||||||
const fadeAnimationProgress = useSharedValue(0)
|
const intro = useSharedValue(0)
|
||||||
const scaleAnimationProgress = useSharedValue(0)
|
const outroLogo = useSharedValue(0)
|
||||||
|
const outroApp = useSharedValue(0)
|
||||||
const [isAnimationComplete, setIsAnimationComplete] = React.useState(false)
|
const [isAnimationComplete, setIsAnimationComplete] = React.useState(false)
|
||||||
|
|
||||||
const logoScaleAnimation = useAnimatedStyle(() => {
|
|
||||||
return {
|
|
||||||
width: interpolate(
|
|
||||||
scaleAnimationProgress.value,
|
|
||||||
[0, 0.2, 0.22, 1],
|
|
||||||
[100, 100, 1000, 1000],
|
|
||||||
'clamp',
|
|
||||||
),
|
|
||||||
height: interpolate(
|
|
||||||
scaleAnimationProgress.value,
|
|
||||||
[0, 0.2, 0.22, 1],
|
|
||||||
[100, 100, 1000, 1000],
|
|
||||||
'clamp',
|
|
||||||
),
|
|
||||||
transform: [
|
|
||||||
{
|
|
||||||
scale: interpolate(
|
|
||||||
scaleAnimationProgress.value,
|
|
||||||
[0, 0.2, 0.22, 1],
|
|
||||||
[1, 0.8, 0.8, 200],
|
|
||||||
'clamp',
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const logoFadeInAnimation = useAnimatedStyle(() => {
|
const logoFadeInAnimation = useAnimatedStyle(() => {
|
||||||
return {
|
return {
|
||||||
opacity: interpolate(
|
/*
|
||||||
fadeAnimationProgress.value,
|
* N.B. these two transforms _compound_, just like with CSS. The first
|
||||||
[0, 0.5, 1],
|
* handles the intro animation at 1:1 scale (1000 px), the second scales
|
||||||
[0, 1, 1],
|
* down by 10x to 100px to get a natural looking 100px wide logo.
|
||||||
'clamp',
|
*/
|
||||||
),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const appScaleAnimation = useAnimatedStyle(() => {
|
|
||||||
return {
|
|
||||||
transform: [
|
transform: [
|
||||||
|
{
|
||||||
|
scale: interpolate(intro.value, [0, 1], [0.8, 1], 'clamp'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
scale: interpolate(
|
scale: interpolate(
|
||||||
scaleAnimationProgress.value,
|
outroLogo.value,
|
||||||
[0, 0.22, 0.5, 1],
|
[0, 0.08, 0.1, 1],
|
||||||
[1.1, 1.09, 1.08, 1],
|
[0.1, 0.08, 0.08, 80],
|
||||||
'clamp',
|
'clamp',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
opacity: interpolate(intro.value, [0, 1], [0, 1], 'clamp'),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// const opacityScale = { opacity: 1 }
|
const appAnimation = useAnimatedStyle(() => {
|
||||||
const appFadeInAnimation = useAnimatedStyle(() => {
|
|
||||||
return {
|
return {
|
||||||
opacity: interpolate(
|
transform: [
|
||||||
scaleAnimationProgress.value,
|
{
|
||||||
[0, 0.22, 1],
|
scale: interpolate(
|
||||||
[0, 0, 1],
|
outroApp.value,
|
||||||
'clamp',
|
[0, 0.7, 1],
|
||||||
),
|
[1.1, 1.1, 1],
|
||||||
|
'clamp',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
opacity: interpolate(outroApp.value, [0, 0.7, 1], [0, 0, 1], 'clamp'),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -98,13 +74,20 @@ export function Splash(props: React.PropsWithChildren<Props>) {
|
|||||||
SplashScreen.hideAsync().catch(() => {})
|
SplashScreen.hideAsync().catch(() => {})
|
||||||
|
|
||||||
if (props.isReady) {
|
if (props.isReady) {
|
||||||
fadeAnimationProgress.value = withTiming(
|
intro.value = withTiming(
|
||||||
1,
|
1,
|
||||||
{duration: 800, easing: Easing.inOut(Easing.cubic)},
|
{duration: 200, easing: Easing.out(Easing.cubic)},
|
||||||
() => {
|
async () => {
|
||||||
scaleAnimationProgress.value = withTiming(
|
outroLogo.value = withTiming(
|
||||||
1,
|
1,
|
||||||
{duration: 1200, easing: Easing.inOut(Easing.cubic)},
|
{duration: 1000, easing: Easing.in(Easing.cubic)},
|
||||||
|
() => {
|
||||||
|
runOnJS(onFinish)()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
outroApp.value = withTiming(
|
||||||
|
1,
|
||||||
|
{duration: 1000, easing: Easing.inOut(Easing.cubic)},
|
||||||
() => {
|
() => {
|
||||||
runOnJS(onFinish)()
|
runOnJS(onFinish)()
|
||||||
},
|
},
|
||||||
@@ -112,7 +95,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}, [onFinish, fadeAnimationProgress, scaleAnimationProgress, props.isReady])
|
}, [onFinish, intro, outroLogo, outroApp, props.isReady])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1}}>
|
<View style={{flex: 1}}>
|
||||||
@@ -135,9 +118,8 @@ export function Splash(props: React.PropsWithChildren<Props>) {
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
logoFadeInAnimation,
|
|
||||||
]}>
|
]}>
|
||||||
<AnimatedLogo width={100} style={[logoScaleAnimation]} />
|
<AnimatedLogo width={1000} style={[logoFadeInAnimation]} />
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
}>
|
}>
|
||||||
{!isAnimationComplete && (
|
{!isAnimationComplete && (
|
||||||
@@ -146,8 +128,7 @@ export function Splash(props: React.PropsWithChildren<Props>) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Animated.View
|
<Animated.View style={[{flex: 1}, appAnimation]}>
|
||||||
style={[{flex: 1}, appFadeInAnimation, appScaleAnimation]}>
|
|
||||||
{props.children}
|
{props.children}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</MaskedView>
|
</MaskedView>
|
||||||
|
|||||||
Reference in New Issue
Block a user