diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index f5d3fb6..9f3d451 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -107,9 +107,14 @@ export const EachStopList = ({ {station} - {points ? ( - 🚊 - ) : null} + + {points ? ( + + 🚊 + + ) : null} + + {!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && ( false); + const [isJumped, setIsJumped] = useState(false); + useEffect(() => { + if (isJumped) return () => {}; + if (!points) return () => {}; + if (points.length == 0) return () => {}; + const position = points.findIndex((d) => d == true); + if (position == -1) return () => {}; + if (trainDataWidhThrough[position].split(",")[1] == "通過") { + LayoutAnimation.configureNext({ + duration: 400, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setShowThrew(true); + } + if(position < 5) return() => {}; // 5駅以内の場合はスクロールしない + const count = position * 44-50; + // 0.5秒待機してからスクロール + setTimeout( + () => ScrollViewRef.current?.scrollTo({ y: count, animated: true }), + 400 + ); + setIsJumped(true); + }, [points]); const trainName = useMemo(() => { if (!data.limited) return ""; const limitedArray = data.limited.split(":"); @@ -198,6 +222,7 @@ export const EachTrainInfoCore = ({ const { height } = useWindowDimensions(); const { isLandscape } = useDeviceOrientationChange(); + const ScrollViewRef = useRef(); const [trueTrainID, setTrueTrainID] = useState(); useEffect(() => { @@ -389,6 +414,7 @@ export const EachTrainInfoCore = ({ from={from} styles={styles} actionSheetRef={actionSheetRef} + ScrollViewRef={ScrollViewRef} containerProps={{ style: { maxHeight: isLandscape ? height - 94 : (height / 100) * 70, diff --git a/components/DynamicHeaderScrollView.js b/components/DynamicHeaderScrollView.js index 5602473..180eae2 100644 --- a/components/DynamicHeaderScrollView.js +++ b/components/DynamicHeaderScrollView.js @@ -13,14 +13,13 @@ export const DynamicHeaderScrollView = (props) => { topStickyContent, styles, from, + ScrollViewRef, } = props; const [headerSize, setHeaderSize] = useState("default"); useLayoutEffect(() => { AS.getItem("headerSize") .then((res) => { - if (res) { - setHeaderSize(res); - } + if (res) setHeaderSize(res); }) .catch((e) => { AS.setItem("headerSize", "default"); @@ -160,6 +159,7 @@ export const DynamicHeaderScrollView = (props) => { stickyHeaderIndices={[1]} scrollEventThrottle={16} onScroll={onScroll} + ref={ScrollViewRef} > {topStickyContent && ( diff --git a/components/Settings/LayoutSettings.js b/components/Settings/LayoutSettings.js index 44b36bb..64af443 100644 --- a/components/Settings/LayoutSettings.js +++ b/components/Settings/LayoutSettings.js @@ -131,7 +131,7 @@ export const LayoutSettings = ({ bool={trainPosition} setBool={setTrainPosition} color="red" - str="列車の現在位置をアイコン表示" + str="列車の現在地表示/ジャンプ" /> diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js index 353a75c..5981d75 100644 --- a/lib/eachTrainInfoCoreLib/findReversalPoints.js +++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js @@ -17,31 +17,31 @@ export const findReversalPoints = (array, stopStationIDList) => { }); return a; }); - if (index != -1) { - return index; - } + if (index != -1) return index; } // 駅間の場合 if (array.length == 2) { - const allThroughStation = stopStationIDList.map((d) => { - if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){ - if(d[0] == "M12"){ - return true; - } - else return false; - } - if (d[0] < array[0] && d[0] > array[1]) { - return true; - } else if (d[0] < array[1] && d[0] > array[0]) { - return true; - }else if (d[0] < array[0] && d[0] == array[1]) { - return true; - } else if (d[0] == array[1] && d[0] > array[0]) { - return true; - } + if ( + (array[0] == "M12" && array[1] == "Y09") || + (array[0] == "Y09" && array[1] == "M12") + ) + return d[0] == "M12" ? true : false; - return false; + let returndata = false; + d.forEach((x) => { + if (array[0] < x && x < array[1]) { + returndata = true; + } else if (array[0] < x && x == array[1]) { + returndata = true; + } else if (array[1] == x && x < array[0]) { + returndata = true; + } else if (array[1] < x && x < array[0]) { + returndata = true; + } + }); + + return returndata; }); return allThroughStation; }