Commit 2133a8a8 authored by mxm-web-develop's avatar mxm-web-develop

Merge branch 'main' of gitlab.33.cn:Website/web2022

parents be20a535 e1219160
...@@ -68,7 +68,7 @@ const HoverLink = () =>{ ...@@ -68,7 +68,7 @@ const HoverLink = () =>{
export default function Navbar (props: IAppProps) { export default function Navbar (props: IAppProps) {
const {pathname} = useLocation() const {pathname} = useLocation()
const {data} = React.useContext(AppContext) const {data} = React.useContext(AppContext)
// console.log('nav',data)
return ( return (
<nav className='flex min-w-[1440px] justify-between absolute px-[120px] w-full top-0 z-[99999] py-6 text-sm text-[#061E3B] font-normal '> <nav className='flex min-w-[1440px] justify-between absolute px-[120px] w-full top-0 z-[99999] py-6 text-sm text-[#061E3B] font-normal '>
<div className='left '> <div className='left '>
......
...@@ -76,16 +76,19 @@ const Dots = (props:DotsType)=>{ ...@@ -76,16 +76,19 @@ const Dots = (props:DotsType)=>{
export const ScrollView = (props: ScrollViewType) => { export const ScrollView = (props: ScrollViewType) => {
BScroll.use(MouseWheel); BScroll.use(MouseWheel);
BScroll.use(ScrollBar); BScroll.use(ScrollBar);
BScroll.use(Slide);
BScroll.use(NestedScroll) BScroll.use(NestedScroll)
const { children } = props; BScroll.use(Slide);
// const location = useLocation()
const wrapRef = useRef<HTMLDivElement>(null); const wrapRef = useRef<HTMLDivElement>(null);
const location = useLocation() const {data,dispatch} = useContext(AppContext)
const { children } = props;
const [dots,setDots]= useState(0) const [dots,setDots]= useState(0)
const [scrollObj, setScrollObj] = useState<BScrollConstructor<{}>>(); const [scrollObj, setScrollObj] = useState<BScrollConstructor<{}>>();
const [currentPage,setCurrentPage] = useState(0) const [currentPage,setCurrentPage] = useState(0)
const {data,dispatch} = useContext(AppContext)
useEffect(()=>{ useEffect(()=>{
const scrollEl = initBScroll(wrapRef.current as HTMLDivElement) const scrollEl = initBScroll(wrapRef.current as HTMLDivElement)
setScrollObj(scrollEl) setScrollObj(scrollEl)
...@@ -107,7 +110,10 @@ export const ScrollView = (props: ScrollViewType) => { ...@@ -107,7 +110,10 @@ export const ScrollView = (props: ScrollViewType) => {
scrollObj&&scrollObj.on('slidePageChanged', (page:any) => { scrollObj&&scrollObj.on('slidePageChanged', (page:any) => {
setCurrentPage((prevState: number)=>{ setCurrentPage((prevState: number)=>{
if(prevState !== page.pageY){ if(prevState !== page.pageY){
setTimeout(()=>{
dispatch({type:'slideOnChange',payload:{pageIndex:page.pageY}}) dispatch({type:'slideOnChange',payload:{pageIndex:page.pageY}})
},0)
return page.pageY return page.pageY
} }
return prevState return prevState
......
...@@ -32,10 +32,10 @@ const AppReducer = (state:typeof data,action:Actions)=>{ ...@@ -32,10 +32,10 @@ const AppReducer = (state:typeof data,action:Actions)=>{
state.currentPage = payload.currentPage state.currentPage = payload.currentPage
break; break;
} }
console.log(state); // console.log(state);
return state return {...state}
} }
export const AppProvider = (props: any)=>{ export const AppProvider = (props: any)=>{
......
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