TP-71069 | optimising animation in quote offer screen (#12120)
This commit is contained in:
@@ -10,7 +10,9 @@ import {
|
||||
} from "react-native";
|
||||
import Animated, {
|
||||
useAnimatedStyle,
|
||||
useDerivedValue,
|
||||
useSharedValue,
|
||||
withDelay,
|
||||
withTiming,
|
||||
} from "react-native-reanimated";
|
||||
import Colors from "../../../../../assets/colors/colors";
|
||||
@@ -61,19 +63,38 @@ const QuoteOfferScreen = ({
|
||||
y.value = event.nativeEvent.contentOffset.y;
|
||||
};
|
||||
|
||||
const derivedY = useDerivedValue(() => {
|
||||
return y.value;
|
||||
});
|
||||
|
||||
const fabTextStyle = useAnimatedStyle(() => {
|
||||
return {
|
||||
maxWidth: withTiming(
|
||||
y.value < lastScrollPosition.value || y.value <= 0 ? 120 : 0,
|
||||
{ duration: 100 },
|
||||
maxWidth: withDelay(
|
||||
50,
|
||||
withTiming(
|
||||
derivedY.value < lastScrollPosition.value || derivedY.value <= 0
|
||||
? 120
|
||||
: 0,
|
||||
{ duration: 100 },
|
||||
),
|
||||
),
|
||||
paddingRight: withTiming(
|
||||
y.value < lastScrollPosition.value || y.value <= 0 ? 16 : 0,
|
||||
{ duration: 100 },
|
||||
paddingRight: withDelay(
|
||||
50,
|
||||
withTiming(
|
||||
derivedY.value < lastScrollPosition.value || derivedY.value <= 0
|
||||
? 16
|
||||
: 0,
|
||||
{ duration: 100 },
|
||||
),
|
||||
),
|
||||
opacity: withTiming(
|
||||
y.value < lastScrollPosition.value || y.value <= 0 ? 1 : 0,
|
||||
{ duration: 100 },
|
||||
opacity: withDelay(
|
||||
50,
|
||||
withTiming(
|
||||
derivedY.value < lastScrollPosition.value || derivedY.value <= 0
|
||||
? 1
|
||||
: 0,
|
||||
{ duration: 100 },
|
||||
),
|
||||
),
|
||||
};
|
||||
});
|
||||
@@ -88,12 +109,14 @@ const QuoteOfferScreen = ({
|
||||
const headerBgStyle = useAnimatedStyle(() => {
|
||||
if (!animateHeader) return { backgroundColor: Colors.white };
|
||||
return {
|
||||
backgroundColor:
|
||||
y.value > HEADER_LOTTIE_WIDGET_HEIGHT
|
||||
backgroundColor: withTiming(
|
||||
derivedY.value > HEADER_LOTTIE_WIDGET_HEIGHT
|
||||
? Colors.grey
|
||||
: y.value > HEADER_LOTTIE_TITLE_HEIGHT
|
||||
: derivedY.value > HEADER_LOTTIE_TITLE_HEIGHT
|
||||
? Colors.aliceBlue
|
||||
: Colors.transparent,
|
||||
{ duration: 50 },
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user