贴个taro版的,我是先记录滚动位置,监听全屏切换事件,在退出全屏时,延时重置滚动位置.视频全屏播放设置为横屏(direction={90}) , 这样退出全屏时会有过渡,看起来不会卡顿 usePageScroll(({ scrollTop }) => { if (!videoControlStore.isFullScreen) { setScrollTop(scrollTop) } }) <Video onFullscreenChange={({detail})=> { if (!detail.fullScreen) { // scrollTop存在state中 const scroll = scrollTop wx.setPageOrientation({ orientation: 'portrait', complete: () => { console.log('是否全屏', videoControlStore.isFullScreen) console.log('退出全屏portrait', scroll) // 视频全屏,scroll-view会滚动到顶部,退出全屏时需要重新设置scrollTop setTimeout(() => { Taro.pageScrollTo({ scrollTop: scroll, duration: 0, }) setScrollTop(scroll) setTimeout(() => { videoControlStore.setIsFullScreen(false) }, 200) }, 100) }, }) } else { wx.setPageOrientation({ orientation: 'landscape' }) videoControlStore.setIsFullScreen(true) } }} id={videoId} src={item.video!} poster={item.cover} direction={90} ></VideoCard>
iOS scroll-view中video全屏再退出全屏scrollView会自动滚到顶部有解决吗?iOS scroll-view中video全屏再退出全屏scrollView会自动滚到顶部有解决吗?
2022-05-20