diff --git a/src/views/Community/components/DynamicNewsCard/EventScrollList.js b/src/views/Community/components/DynamicNewsCard/EventScrollList.js index 413e2256..77fe5289 100644 --- a/src/views/Community/components/DynamicNewsCard/EventScrollList.js +++ b/src/views/Community/components/DynamicNewsCard/EventScrollList.js @@ -1,7 +1,7 @@ // src/views/Community/components/DynamicNewsCard/EventScrollList.js // 横向滚动事件列表组件 -import React, { useRef, useState, useEffect } from 'react'; +import React, { useRef } from 'react'; import { Box, Flex, @@ -38,49 +38,6 @@ const EventScrollList = ({ loading = false }) => { const scrollContainerRef = useRef(null); - const [showLeftArrow, setShowLeftArrow] = useState(false); - const [showRightArrow, setShowRightArrow] = useState(true); - - // 页码变化时,滚动到左侧起始位置 - useEffect(() => { - if (scrollContainerRef.current) { - scrollContainerRef.current.scrollTo({ - left: 0, - behavior: 'smooth' - }); - } - }, [currentPage]); - - // 滚动到左侧 - const scrollLeft = () => { - if (scrollContainerRef.current) { - scrollContainerRef.current.scrollBy({ - left: -400, - behavior: 'smooth' - }); - } - }; - - // 滚动到右侧 - const scrollRight = () => { - if (scrollContainerRef.current) { - scrollContainerRef.current.scrollBy({ - left: 400, - behavior: 'smooth' - }); - } - }; - - // 监听滚动位置,更新箭头显示状态 - const handleScroll = (e) => { - const container = e.target; - const scrollLeft = container.scrollLeft; - const scrollWidth = container.scrollWidth; - const clientWidth = container.clientWidth; - - setShowLeftArrow(scrollLeft > 0); - setShowRightArrow(scrollLeft < scrollWidth - clientWidth - 10); - }; // 时间轴样式配置 const getTimelineBoxStyle = () => { @@ -97,41 +54,49 @@ const EventScrollList = ({ {/* 横向滚动区域 */} - {/* 左侧滚动按钮 */} - {showLeftArrow && ( + {/* 左侧翻页按钮 - 上一页 */} + {currentPage > 1 && ( } + icon={} position="absolute" - left="-4" + left="2" top="50%" transform="translateY(-50%)" zIndex={2} - onClick={scrollLeft} + onClick={() => onPageChange(currentPage - 1)} colorScheme="blue" variant="solid" - size="md" + size="lg" borderRadius="full" - shadow="md" - aria-label="向左滚动" + shadow="lg" + bg="blue.500" + _hover={{ bg: 'blue.600', transform: 'translateY(-50%) scale(1.1)' }} + _active={{ bg: 'blue.700' }} + aria-label="上一页" + title="上一页" /> )} - {/* 右侧滚动按钮 */} - {showRightArrow && ( + {/* 右侧翻页按钮 - 下一页 */} + {currentPage < totalPages && ( } + icon={} position="absolute" - right="-4" + right="2" top="50%" transform="translateY(-50%)" zIndex={2} - onClick={scrollRight} + onClick={() => onPageChange(currentPage + 1)} colorScheme="blue" variant="solid" - size="md" + size="lg" borderRadius="full" - shadow="md" - aria-label="向右滚动" + shadow="lg" + bg="blue.500" + _hover={{ bg: 'blue.600', transform: 'translateY(-50%) scale(1.1)' }} + _active={{ bg: 'blue.700' }} + aria-label="下一页" + title="下一页" /> )} @@ -143,7 +108,6 @@ const EventScrollList = ({ gap={4} py={4} px={2} - onScroll={handleScroll} position="relative" css={{ '&::-webkit-scrollbar': {