|
@@ -16,16 +16,18 @@ let activeIndex = 0
|
|
|
let lastSwiperItemIndex = 0 // 上个 item 索引
|
|
|
let currentListIndex = 0 // 大视频列表的索引
|
|
|
let isUp = false
|
|
|
+let swiperRefreshing = false
|
|
|
|
|
|
const videoViewedMap = new Map()
|
|
|
|
|
|
-export default function VideoSwiper({ list, onFinish, needResumePlay, flushList }) {
|
|
|
+export default function VideoSwiper({ list, onFinish, needResumePlay, flushList, onRefresh }) {
|
|
|
const [currentIndex, setCurrentIndex] = useState(0)
|
|
|
const [circular, setCircular] = useState(false)
|
|
|
const [videoList, setVideoList] = useState<VideoInfo[]>(list.slice(0, 3))
|
|
|
const [seekProgress, setSeekProgress] = useState(false)
|
|
|
const [needPlayerResume, setNeedPlayerResume] = useState(false)
|
|
|
|
|
|
+
|
|
|
useReady(() => {
|
|
|
activeIndex = 0
|
|
|
videoViewedMap.clear()
|
|
@@ -45,6 +47,20 @@ export default function VideoSwiper({ list, onFinish, needResumePlay, flushList
|
|
|
setSeekProgress(e || false)
|
|
|
}
|
|
|
|
|
|
+ function onTransition(e) {
|
|
|
+ console.log('swo:', e.detail)
|
|
|
+ let {dy = 0} = e.detail
|
|
|
+ if (!swiperRefreshing && dy < -50 && currentListIndex == 0 && currentIndex == 0) {
|
|
|
+ swiperRefreshing = true
|
|
|
+ setTimeout(() => {
|
|
|
+ onRefresh()
|
|
|
+ }, 250);
|
|
|
+ }else if (swiperRefreshing && dy == 0) {
|
|
|
+ swiperRefreshing = false
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function onSwiperChange(res) {
|
|
|
const { detail } = res || {}
|
|
|
const { current } = detail || {}
|
|
@@ -68,9 +84,6 @@ export default function VideoSwiper({ list, onFinish, needResumePlay, flushList
|
|
|
const { current } = detail || {}
|
|
|
|
|
|
if (activeIndex == current) {
|
|
|
- if (currentListIndex == 0) {
|
|
|
- onFinish(-99)
|
|
|
- }
|
|
|
return
|
|
|
}
|
|
|
activeIndex = current
|
|
@@ -139,13 +152,15 @@ export default function VideoSwiper({ list, onFinish, needResumePlay, flushList
|
|
|
className='video-swiper'
|
|
|
vertical
|
|
|
circular={circular}
|
|
|
+ duration={200}
|
|
|
current={currentIndex}
|
|
|
onChange={onSwiperChange}
|
|
|
+ onTransition={onTransition}
|
|
|
onAnimationFinish={onAnimationFinish}
|
|
|
>
|
|
|
{videoList.map((video, index) => {
|
|
|
return (
|
|
|
- <SwiperItem className='video-swiper-item' key={video.id}>
|
|
|
+ <SwiperItem className='video-swiper-item' key={video.id} >
|
|
|
<CustomVideo
|
|
|
video={video}
|
|
|
current={currentIndex}
|
|
@@ -345,6 +360,9 @@ function CustomVideo({ video, current, index, onTimeUpdate, onProgressMove, need
|
|
|
onSeekComplete={onSeekCom}
|
|
|
onTap={onTapVideo}
|
|
|
/>
|
|
|
+ {(playerState == PlayState.pause) && <View className='plaBtn'>
|
|
|
+ <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_play_btn_dark2.png'/>
|
|
|
+ </View>}
|
|
|
<View className='progress-bg'
|
|
|
onTouchStart={onTouchStart}
|
|
|
onTouchMove={onTouchMove}
|