This article shares the specific code of videojs+swiper to realize the carousel of Taobao product details for your reference. The specific content is as follows This one references videojs and swiper. The effect is similar to the carousel pictures in Taobao product details, and the first carousel is a video: swiper manual HTML part: <!-- swiper carousel--> <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> <!-- If you need a pager --> <div class="swiper-pagination"></div> </div> js part: //Create a new videojs object var player = videojs('video', { muted: true, controls: true, // loop: true, }); // swiper carousel var mySwiper = new Swiper ('.swiper-container', { direction:'horizontal', // The direction of the slideshow, can also be vertical loop: true, // loop play autoplay:3000, // slide automatic switching time speed:2000, // slide sliding animation time height: 100, pagination: '.swiper-pagination', // If you need a paginator, that is, the small dot below autoplayDisableOnInteraction : false, // In this way, even if we slide, the timer will not be cleared offsetWidth: 0, observer:true, //Monitor // When swiper transitions from one slide to another, execute: stop video playback (here is swiper3, swiper4 is written differently) onSlideChangeStart: function(swiper){ player.pause(); } }); //Stop the carousel while the video is playingplayer.on('play',function(){ // console.log(mySwiper) mySwiper.stopAutoplay() }); // When the video is paused, the carousel continues player.on('pause', function(){ mySwiper.startAutoplay() }); The js and css of swiper and videojs are not introduced here, you can search them on Baidu. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to delete garbled or special character files in Linux
>>: MySQL Order By Multi-Field Sorting Rules Code Example
This article example shares the specific code for...
1. Add a new user Only allow local IP access crea...
Preface The general methods are not listed here, ...
1 Introduction When designing a database, it is i...
1. Install mutt sudo apt-get install mutt 2. Inst...
Here we introduce the knowledge about form elemen...
From: https://blog.csdn.net/qq_44761243/article/d...
The GtkTreeView component is an advanced componen...
The effect diagram is as follows: <!DOCTYPE ht...
Table of contents question: There are 2 tokens in...
The final effect is as follows: The animation is ...
Understanding of polling In fact, the focus of po...
Table of contents 1. Customize plan tasks 2. Sync...
The previous article introduced the installation ...
Placing a search box in the top menu bar is a com...