挙動修正

This commit is contained in:
harukin-OneMix4 2024-02-08 19:18:28 +09:00
parent 49e9ed14bc
commit cb2562fe9c
2 changed files with 84 additions and 52 deletions

View File

@ -460,19 +460,32 @@ export const EachTrainInfo = (props) => {
openTrainInfo={openTrainInfo} openTrainInfo={openTrainInfo}
/> />
)} )}
<ScrollView <ScrollView
{...scrollHandlers} {...scrollHandlers}
style={{ style={{
backgroundColor: "white", backgroundColor: "white",
}} }}
stickyHeaderIndices={[0]} stickyHeaderIndices={[1]}
scrollEventThrottle={16} scrollEventThrottle={16}
onScroll={Animated.event( onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: scrollOffsetY } } }], [{ nativeEvent: { contentOffset: { y: scrollOffsetY } } }],
{ useNativeDriver: false } { useNativeDriver: false }
)} )}
> >
<View
style={{
height: from == "AllTrainDiagramView" ? 0 : 120,
flexDirection: "column",
}}
/>
<View
style={{
height: from == "AllTrainDiagramView" ? "auto" : 120,
flexDirection: "column",
}}
index={1}
>
<View style={{ flex: 1 }} />
<View <View
style={{ style={{
alignItems: "center", alignItems: "center",
@ -525,6 +538,8 @@ export const EachTrainInfo = (props) => {
</View> </View>
</View> </View>
</View> </View>
</View>
{headStation && !isConcatNear && ( {headStation && !isConcatNear && (
<TouchableOpacity <TouchableOpacity
onPress={() => openBackTrainInfo(headStation)} onPress={() => openBackTrainInfo(headStation)}

View File

@ -1,6 +1,10 @@
import * as React from "react"; import * as React from "react";
import { Text, View, StyleSheet, Animated, ScrollView } from "react-native"; import { Text, View, StyleSheet, Animated, ScrollView } from "react-native";
import { TrainDataView } from "./TrainDataView"; import { TrainDataView } from "./TrainDataView";
import {
heightPercentageToDP,
widthPercentageToDP,
} from "react-native-responsive-screen";
const Max_Header_Height = 200; const Max_Header_Height = 200;
const Min_Header_Height = 80; const Min_Header_Height = 80;
@ -13,28 +17,36 @@ export const DynamicHeader = ({
openTrainInfo, openTrainInfo,
}) => { }) => {
const animatedHeaderHeight = animHeaderValue.interpolate({ const animatedHeaderHeight = animHeaderValue.interpolate({
inputRange: [0, Scroll_Distance], inputRange: [Min_Header_Height, Scroll_Distance],
outputRange: [Max_Header_Height, 0], outputRange: [Max_Header_Height, 0],
extrapolate: "clamp", extrapolate: "clamp",
}); });
const animatedHeaderHeight2 = animHeaderValue.interpolate({ const animatedHeaderHeight2 = animHeaderValue.interpolate({
inputRange: [0, Scroll_Distance], inputRange: [0, Scroll_Distance],
outputRange: [0, Min_Header_Height], outputRange: [Max_Header_Height, Min_Header_Height],
extrapolate: "clamp", extrapolate: "clamp",
}); });
const animateHeaderBackgroundColor = animHeaderValue.interpolate({ const animatedHeaderVisible = animHeaderValue.interpolate({
inputRange: [0, Max_Header_Height - Min_Header_Height], inputRange: [Min_Header_Height, Scroll_Distance],
outputRange: ["blue", "red"], outputRange: [1, 0],
extrapolate: "clamp",
});
const animatedHeaderVisible2 = animHeaderValue.interpolate({
inputRange: [Min_Header_Height, Scroll_Distance],
outputRange: [0, 1],
extrapolate: "clamp", extrapolate: "clamp",
}); });
return ( return (
<> <View style={{ position: "relative" }}>
<Animated.View <Animated.View
style={[ style={[
styles.header, styles.header,
{ {
height: animatedHeaderHeight, height: 200,
// backgroundColor: animateHeaderBackgroundColor, backgroundColor: "#0099CC",
opacity: animatedHeaderVisible,
top: 0,
}, },
]} ]}
> >
@ -145,8 +157,10 @@ export const DynamicHeader = ({
styles.header, styles.header,
{ {
height: animatedHeaderHeight2, height: animatedHeaderHeight2,
//backgroundColor: animateHeaderBackgroundColor, backgroundColor: "#0099CC",
margin: 0, margin: 0,
top: 0,
opacity: animatedHeaderVisible2,
}, },
]} ]}
> >
@ -254,7 +268,7 @@ export const DynamicHeader = ({
</View> */} </View> */}
</ScrollView> </ScrollView>
</Animated.View> </Animated.View>
</> </View>
); );
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
@ -264,6 +278,9 @@ const styles = StyleSheet.create({
left: 0, left: 0,
right: 0, right: 0,
//paddingTop: 10, //paddingTop: 10,
position: "absolute",
zIndex: 1,
backgroundColor: "f0f0f0",
}, },
headerText: { headerText: {
color: "#fff", color: "#fff",