添加选择过度
This commit is contained in:
@@ -206,13 +206,12 @@ box-sizing: border-box;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
transform: rotate(45deg);
|
||||
|
||||
transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
&.rotated {
|
||||
.closeIcon{
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ interface IProps {
|
||||
leftIconClick?: () => void;
|
||||
};
|
||||
onCityPickerVisibleChange?: (visible: boolean) => void; // 城市选择器显示/隐藏回调
|
||||
onScrollToTop?: () => void; // 滚动到顶部回调
|
||||
}
|
||||
|
||||
function CityPicker(props) {
|
||||
@@ -50,7 +51,7 @@ function CityPicker(props) {
|
||||
}
|
||||
|
||||
const ListHeader = (props: IProps) => {
|
||||
const { config, onCityPickerVisibleChange } = props;
|
||||
const { config, onCityPickerVisibleChange, onScrollToTop } = props;
|
||||
const { showInput = false, inputLeftIcon, leftIconClick } = config || {};
|
||||
const { getLocationLoading, statusNavbarHeightInfo } = useGlobalState();
|
||||
const { gamesNum, searchValue, cities, area, updateArea, getMatchesData, fetchGetGamesCount, refreshBothLists } = useListState();
|
||||
@@ -89,10 +90,16 @@ const ListHeader = (props: IProps) => {
|
||||
const handleLogoClick = () => {
|
||||
// 如果当前在列表页,点击后页面回到顶部
|
||||
if (getCurrentFullPath() === "/game_pages/list/index") {
|
||||
Taro.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300,
|
||||
});
|
||||
// 使用父组件传递的滚动方法(适配 ScrollView)
|
||||
if (onScrollToTop) {
|
||||
onScrollToTop();
|
||||
} else {
|
||||
// 降级方案:使用页面滚动(兼容旧版本)
|
||||
Taro.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300,
|
||||
});
|
||||
}
|
||||
}
|
||||
Taro.redirectTo({
|
||||
url: "game_pages/list/index", // 列表页
|
||||
|
||||
@@ -63,6 +63,7 @@ const ListPage = () => {
|
||||
|
||||
// 滚动相关状态
|
||||
const scrollContextRef = useRef(null);
|
||||
const scrollViewRef = useRef(null); // ScrollView 的 ref
|
||||
const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const lastScrollTopRef = useRef(0);
|
||||
const scrollDirectionRef = useRef<'up' | 'down' | null>(null);
|
||||
@@ -70,6 +71,7 @@ const ListPage = () => {
|
||||
const loadingMoreRef = useRef(false); // 防止重复加载更多
|
||||
const scrollStartPositionRef = useRef(0); // 记录开始滚动的位置
|
||||
const [showSearchBar, setShowSearchBar] = useState(true); // 控制搜索框显示/隐藏(筛选始终显示)
|
||||
const [scrollTop, setScrollTop] = useState(0); // 控制 ScrollView 滚动位置
|
||||
|
||||
// 动态控制 GuideBar 的 z-index
|
||||
const [guideBarZIndex, setGuideBarZIndex] = useState<'low' | 'high'>('high');
|
||||
@@ -92,6 +94,12 @@ const ListPage = () => {
|
||||
setIsCityPickerVisible(visible);
|
||||
}, []);
|
||||
|
||||
// 滚动到顶部的方法
|
||||
const scrollToTop = useCallback(() => {
|
||||
// 使用一个唯一值触发 scrollTop 更新,确保每次都能滚动到顶部
|
||||
setScrollTop(prev => prev === 0 ? 0.1 : 0);
|
||||
}, []);
|
||||
|
||||
// 监听所有弹窗和菜单的状态,动态调整 GuideBar 的 z-index
|
||||
useEffect(() => {
|
||||
if (isPublishMenuVisible) {
|
||||
@@ -432,6 +440,7 @@ const ListPage = () => {
|
||||
showInput: isShowInputCustomerNavBar,
|
||||
}}
|
||||
onCityPickerVisibleChange={handleCityPickerVisibleChange}
|
||||
onScrollToTop={scrollToTop}
|
||||
/>
|
||||
{area_city !== "上海" ? (
|
||||
renderCityQrcode()
|
||||
@@ -485,7 +494,9 @@ const ListPage = () => {
|
||||
|
||||
{/* 可滚动的列表内容 */}
|
||||
<ScrollView
|
||||
ref={scrollViewRef}
|
||||
scrollY
|
||||
scrollTop={scrollTop}
|
||||
className={styles.listScrollView}
|
||||
scrollWithAnimation
|
||||
enhanced
|
||||
|
||||
Reference in New Issue
Block a user