Commit 6380fe57 authored by salitedfish's avatar salitedfish

feat: 关于我们添加上下页按钮

parent c8f258dd
...@@ -10,6 +10,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "r ...@@ -10,6 +10,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "r
interface ScrollViewType extends IProps { interface ScrollViewType extends IProps {
wrapHeight?: string; wrapHeight?: string;
prop?: any; prop?: any;
getScrollHandler?: (next: Function, prev: Function) => void
} }
const initBScroll = (el:HTMLElement) => { const initBScroll = (el:HTMLElement) => {
...@@ -57,6 +58,9 @@ export const EventsScrollView = (props: ScrollViewType) => { ...@@ -57,6 +58,9 @@ export const EventsScrollView = (props: ScrollViewType) => {
useEffect(()=>{ useEffect(()=>{
const scrollEl = initBScroll(wrapRef.current as HTMLDivElement) const scrollEl = initBScroll(wrapRef.current as HTMLDivElement)
setScrollObj(scrollEl) setScrollObj(scrollEl)
if(props.getScrollHandler) {
props.getScrollHandler(scrollEl.next, scrollEl.prev)
}
return () => { return () => {
scrollObj?.destroy(); scrollObj?.destroy();
}; };
......
import { IProps } from "@/common/Iprops.interface" import { IProps } from "@/common/Iprops.interface"
import { AppContianer } from "@/layouts/AppContianer" import { AppContianer } from "@/layouts/AppContianer"
import { useRef, useState, useEffect, useMemo, useCallback } from 'react' import { useRef, useState, useEffect, useMemo, useCallback, Fragment } from 'react'
import { getEvents } from "@/fetch/dataFetch" import { getEvents } from "@/fetch/dataFetch"
import { EventItem, EventsTable } from "./EventItem" import { EventItem, EventsTable } from "./EventItem"
import { EventsScrollView } from "@/components/EventsScrollView" import { EventsScrollView } from "@/components/EventsScrollView"
import Step from "@/assets/img/step.png"
interface MemorabiliaType extends IProps { interface MemorabiliaType extends IProps {
...@@ -22,37 +24,59 @@ export const Memorabilia = () => { ...@@ -22,37 +24,59 @@ export const Memorabilia = () => {
return ()=> fetchData.unsubscribe() return ()=> fetchData.unsubscribe()
},[currentSlide]) },[currentSlide])
const scrollHandler: {
next?: Function
prev?: Function
} = {}
const getScrollHandler = (next: Function, prev: Function) => {
scrollHandler.next = next
scrollHandler.prev = prev
}
const scrollTo = (step: number) => {
switch(step) {
case 1:
scrollHandler.next ? scrollHandler.next() : null;
break
case -1:
scrollHandler.prev ? scrollHandler.prev() : null;
break
}
}
return ( return (
<AppContianer className="flex items-center justify-start h-full w-full relative labtop:px-[120px] "> <AppContianer className="flex items-center justify-start h-full w-full relative labtop:px-[120px] ">
<div className='w-[896px]'> <div className='w-[896px]'>
<div className='absolute top-12 labtop:right-[14rem] right-[7rem]'> <div className='absolute top-12 labtop:right-[14rem] right-[7rem]'>
<div className="hero-title">Memorabilia</div> <div className="hero-title">Memorabilia</div>
<div className="subTitle-1-cn py-3 flex items-center gap-x-5"> <div className="subTitle-1-cn py-3 flex items-center gap-x-5">
<div className=" w-28 h-1 bg-theme-dark rounded"></div> <div className=" w-28 h-1 bg-theme-dark rounded"></div>
<div>功能特点</div> <div>功能特点</div>
</div>
</div> </div>
</div> {
{ data?
data? <div className="relative">
<EventsScrollView> <img className='absolute top-96 -left-16 rotate-180 opacity-30 hover:opacity-100 cursor-pointer' onClick={() => scrollTo(-1)} src={Step} alt="" />
<div className='flex '> <EventsScrollView getScrollHandler={getScrollHandler}>
{ <div className='flex '>
data.length>0&&data.map((g:any,index:number)=>( {
<div className='w-full h-[800px] translate-y-[60px] ' key={index}> data.length>0&&data.map((g:any,index:number)=>(
<EventsTable tableIndex={currentSlide} data={g} ></EventsTable> <div className='w-full h-[800px] translate-y-[60px] ' key={index}>
</div> <EventsTable tableIndex={currentSlide} data={g} ></EventsTable>
)) </div>
} ))
</div> }
</EventsScrollView>
:
<div>
loading
</div> </div>
} </EventsScrollView>
<img className='absolute top-96 -right-16 opacity-30 hover:opacity-100 cursor-pointer' onClick={() => scrollTo(1)} src={Step} alt="" />
</div>
:
<div>
loading
</div>
}
</div> </div>
</AppContianer > </AppContianer >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment