Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web2022
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Website
web2022
Commits
e1219160
Commit
e1219160
authored
Aug 03, 2022
by
louyuqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
context
parent
c3062bc9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
index.tsx
src/components/Navbar/index.tsx
+1
-1
ScrollView.tsx
src/components/ScrollView.tsx
+13
-7
AppProvider.tsx
src/store/AppProvider.tsx
+2
-2
No files found.
src/components/Navbar/index.tsx
View file @
e1219160
...
...
@@ -68,7 +68,7 @@ const HoverLink = () =>{
export
default
function
Navbar
(
props
:
IAppProps
)
{
const
{
pathname
}
=
useLocation
()
const
{
data
}
=
React
.
useContext
(
AppContext
)
// console.log('nav',data)
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 '
>
<
div
className=
'left '
>
...
...
src/components/ScrollView.tsx
View file @
e1219160
...
...
@@ -76,18 +76,21 @@ const Dots = (props:DotsType)=>{
export
const
ScrollView
=
(
props
:
ScrollViewType
)
=>
{
BScroll
.
use
(
MouseWheel
);
BScroll
.
use
(
ScrollBar
);
BScroll
.
use
(
Slide
);
BScroll
.
use
(
NestedScroll
)
const
{
children
}
=
props
;
BScroll
.
use
(
Slide
);
// const location = useLocation()
const
wrapRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
location
=
useLocation
()
const
{
data
,
dispatch
}
=
useContext
(
AppContext
)
const
{
children
}
=
props
;
const
[
dots
,
setDots
]
=
useState
(
0
)
const
[
scrollObj
,
setScrollObj
]
=
useState
<
BScrollConstructor
<
{}
>>
();
const
[
currentPage
,
setCurrentPage
]
=
useState
(
0
)
const
{
data
,
dispatch
}
=
useContext
(
AppContext
)
useEffect
(()
=>
{
const
scrollEl
=
initBScroll
(
wrapRef
.
current
as
HTMLDivElement
)
const
scrollEl
=
initBScroll
(
wrapRef
.
current
as
HTMLDivElement
)
setScrollObj
(
scrollEl
)
return
()
=>
{
scrollEl
.
destroy
();
...
...
@@ -107,7 +110,10 @@ export const ScrollView = (props: ScrollViewType) => {
scrollObj
&&
scrollObj
.
on
(
'slidePageChanged'
,
(
page
:
any
)
=>
{
setCurrentPage
((
prevState
:
number
)
=>
{
if
(
prevState
!==
page
.
pageY
){
dispatch
({
type
:
'slideOnChange'
,
payload
:{
pageIndex
:
page
.
pageY
}})
setTimeout
(()
=>
{
dispatch
({
type
:
'slideOnChange'
,
payload
:{
pageIndex
:
page
.
pageY
}})
},
0
)
return
page
.
pageY
}
return
prevState
...
...
src/store/AppProvider.tsx
View file @
e1219160
...
...
@@ -32,10 +32,10 @@ const AppReducer = (state:typeof data,action:Actions)=>{
state
.
currentPage
=
payload
.
currentPage
break
;
}
console
.
log
(
state
);
//
console.log(state);
return
state
return
{...
state
}
}
export
const
AppProvider
=
(
props
:
any
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment