亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

videojs+swiper實(shí)現(xiàn)淘寶商品詳情輪播圖

 更新時(shí)間:2021年04月19日 09:30:21   作者:NHPH  
這篇文章主要為大家詳細(xì)介紹了videojs+swiper實(shí)現(xiàn)淘寶商品詳情輪播圖,輪播翻動(dòng),視頻暫停,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了videojs+swiper實(shí)現(xiàn)淘寶商品詳情輪播圖的具體代碼,供大家參考,具體內(nèi)容如下

這個(gè)引用了videojs和swiper。實(shí)現(xiàn)效果類似淘寶商品詳情中的輪播圖,首張輪播為視頻:
當(dāng)視頻開始播放時(shí),輪播停止。視頻暫停時(shí),輪播繼續(xù)。
當(dāng)視頻播放中,滑動(dòng)到下個(gè)slide時(shí),視頻暫停播放。

swiper手冊(cè)

HTML部分:

<!-- swiper輪播 -->
<div class="swiper-container">
   <div class="swiper-wrapper">
       <div class="swiper-slide">
           <video id="video" style="width: 100%;height: 100%;"  controls preload="none" poster="xxxx" class="video-js vjs-big-play-centered" >
            <source src="xxxx" type="video/mp4">
           </video>
       </div>
       <div class="swiper-slide"><img src="xxxx" alt=""></div>
        <div class="swiper-slide"><img src="xxxx" alt=""></div>
        <div class="swiper-slide"><img src="xxxx" alt=""></div>
        <div class="swiper-slide"><img src="xxxx" alt=""></div>
   </div>
   <!-- 如果需要分頁(yè)器 -->
   <div class="swiper-pagination"></div>
</div>

js部分:

//新建videojs對(duì)象
var player = videojs('video', {
     muted: true,
     controls: true,
     // loop: true,
 });

 // swiper輪播
 var mySwiper = new Swiper ('.swiper-container', {
     direction:'horizontal', // 輪播圖的方向,也可以是vertical方向
     loop: true,  //循環(huán)播放
     autoplay:3000,// slide自動(dòng)切換時(shí)間
     speed:2000,// slide滑動(dòng)動(dòng)畫時(shí)間
     height: 100,
     pagination: '.swiper-pagination',  // 如果需要分頁(yè)器,即下面的小圓點(diǎn)
     autoplayDisableOnInteraction : false,// 這樣,即使我們滑動(dòng)之后, 定時(shí)器也不會(huì)被清除
     offsetWidth: 0,
     observer:true,   //監(jiān)聽

     // swiper從一個(gè)slide過渡到另一個(gè)slide時(shí)執(zhí)行:停止視頻播放(這里是swiper3,swiper4的寫法不同)
     onSlideChangeStart: function(swiper){
          player.pause();
     }
 });


 //視頻播放時(shí)輪播圖停止
 player.on('play',function(){
     // console.log(mySwiper)
     mySwiper.stopAutoplay()
 });

 // 視頻暫停時(shí)輪播圖繼續(xù)
 player.on('pause',function(){
     mySwiper.startAutoplay()
 });

這里沒有引入swiper和videojs的js和css,可自行百度。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論