Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
f2d0e769
Commit
f2d0e769
authored
May 12, 2023
by
刘梦焕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 轮播交互修改
parent
ba6b52f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
85 deletions
+54
-85
demo.tsx
packages/base-components/VideoSliderModal/src/demos/demo.tsx
+9
-1
index.js
packages/base-components/VideoSliderModal/src/index.js
+45
-65
index.less
packages/base-components/VideoSliderModal/src/index.less
+0
-19
No files found.
packages/base-components/VideoSliderModal/src/demos/demo.tsx
View file @
f2d0e769
...
...
@@ -49,10 +49,18 @@ const Demo = () => {
},
];
const
_JessibucaObj
=
{
operateBtns
:
{
screenshot
:
false
,
},
loadingText
:
'视频加载中'
,
decoder
:
'/JessibucaVideo/decoder.js'
,
};
return
(
<>
<
Button
onClick=
{
()
=>
setShowModal
(
true
)
}
>
打开弹窗
</
Button
>
<
VideoSliderModal
modalInfo=
{
modalInfo
}
videoInfos=
{
videos
}
/>
<
VideoSliderModal
modalInfo=
{
modalInfo
}
videoInfos=
{
videos
}
JessibucaObj=
{
_JessibucaObj
}
/>
</>
);
};
...
...
packages/base-components/VideoSliderModal/src/index.js
View file @
f2d0e769
import
VmsVideo
from
'@wisdom-components/VmsVideo'
;
import
{
Modal
,
Space
}
from
'antd'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Modal
}
from
'antd'
;
import
React
from
'react'
;
import
SwiperCore
,
{
Autoplay
,
Lazy
,
Navigation
,
Pagination
,
Virtual
}
from
'swiper'
;
import
{
Swiper
,
SwiperSlide
}
from
'swiper/react'
;
import
'swiper/swiper.min.css'
;
...
...
@@ -10,36 +10,24 @@ SwiperCore.use([Virtual, Navigation, Lazy, Autoplay, Pagination]);
const
VideoSliderModal
=
(
props
)
=>
{
const
{
modalInfo
,
videoInfos
,
JessibucaObj
}
=
props
;
const
[
swiper
,
setSwiper
]
=
useState
(
null
);
const
[
activeIndex
,
setActiveIndex
]
=
useState
(
0
);
const
handleNavigation
=
(
direction
)
=>
{
if
(
swiper
)
{
if
(
direction
===
'prev'
)
{
swiper
.
slidePrev
();
}
else
if
(
direction
===
'next'
)
{
swiper
.
slideNext
();
}
// 切换轮播页 控制按钮是否显示
const
handleSlideChange
=
(
swiper
)
=>
{
const
nextButton
=
document
.
querySelector
(
'.swiper-button-next'
);
const
prevButton
=
document
.
querySelector
(
'.swiper-button-prev'
);
if
(
swiper
.
isBeginning
)
{
prevButton
.
style
.
display
=
'none'
;
// 隐藏左侧按钮
}
else
{
prevButton
.
style
.
display
=
'block'
;
// 显示左侧按钮
}
};
const
handlePaginationClick
=
(
index
)
=>
{
setActiveIndex
(
index
);
if
(
swiper
)
{
swiper
.
slideTo
(
index
);
if
(
swiper
.
isEnd
)
{
nextButton
.
style
.
display
=
'none'
;
// 隐藏右侧按钮
}
else
{
nextButton
.
style
.
display
=
'block'
;
// 显示右侧按钮
}
};
// 默认配置
const
_JessibucaObj
=
{
operateBtns
:
{
screenshot
:
false
,
},
loadingText
:
'视频加载中'
,
decoder
:
'/JessibucaVideo/decoder.js'
,
...
JessibucaObj
,
};
return
(
<
Modal
footer
=
{
null
}
...
...
@@ -51,45 +39,37 @@ const VideoSliderModal = (props) => {
getContainer
=
{
document
.
body
}
destroyOnClose
>
<
Swiper
onSwiper
=
{
setSwiper
}
slidesPerView
=
{
1
}
spaceBetween
=
{
0
}
pagination
=
{{
clickable
:
true
,
}}
loop
lazy
virtual
onActiveIndexChange
=
{(
e
)
=>
{
setActiveIndex
(
e
.
activeIndex
);
}}
navigation
>
{
videoInfos
.
map
((
item
,
index
)
=>
(
<
SwiperSlide
key
=
{
index
}
>
<
div
className
=
{
styles
[
'swiper-wrap'
]}
>
<
div
className
=
{
styles
[
'swiper-title'
]}
>
{
item
.
name
}
<
/div
>
<
div
className
=
{
styles
[
'swiper-content'
]}
>
<
VmsVideo
VideoInfo
=
{
item
}
JessibucaObj
=
{
_JessibucaObj
}
/
>
<
/div
>
<
/div
>
<
/SwiperSlide
>
))}
<
/Swiper
>
<
div
className
=
{
styles
[
'swiper-dots-wrap'
]}
>
<
Space
size
=
{
16
}
>
{
videoInfos
.
map
((
video
,
index
)
=>
(
<
div
className
=
{
styles
[
'swiper-dots'
]}
key
=
{
index
}
onClick
=
{()
=>
handlePaginationClick
(
index
)}
style
=
{{
background
:
activeIndex
===
index
?
'#007aff'
:
'#919090'
}}
/
>
))}
<
/Space
>
<
/div
>
<>
{
videoInfos
.
length
===
1
?
(
videoInfos
.
map
((
item
,
index
)
=>
<
VmsVideo
VideoInfo
=
{
item
}
JessibucaObj
=
{
JessibucaObj
}
/>
)
)
:
(
<>
<
Swiper
slidesPerView
=
{
1
}
spaceBetween
=
{
0
}
initialSlide
=
{
0
}
pagination
=
{{
clickable
:
true
,
}}
lazy
virtual
navigation
onSlideChange
=
{(
swiper
)
=>
handleSlideChange
(
swiper
)}
>
{
videoInfos
.
map
((
item
,
index
)
=>
(
<
SwiperSlide
key
=
{
index
}
>
<
div
className
=
{
styles
[
'swiper-wrap'
]}
>
<
div
className
=
{
styles
[
'swiper-title'
]}
>
{
item
.
name
}
<
/div
>
<
div
className
=
{
styles
[
'swiper-content'
]}
>
<
VmsVideo
VideoInfo
=
{
item
}
JessibucaObj
=
{
JessibucaObj
}
/
>
<
/div
>
<
/div
>
<
/SwiperSlide
>
))}
<
/Swiper
>
<
/
>
)}
<
/
>
<
/Modal
>
);
};
...
...
packages/base-components/VideoSliderModal/src/index.less
View file @
f2d0e769
...
...
@@ -29,23 +29,4 @@
flex: 1;
}
}
.swiper-dots-wrap {
position: absolute;
bottom: 8px;
left: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 22px;
.swiper-dots {
width: 8px;
height: 8px;
background: #919090;
border-radius: 50%;
}
}
}
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