Videojs+swiper realizes Taobao product details carousel

Videojs+swiper realizes Taobao product details carousel

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:
When the video starts playing, the carousel stops. When the video is paused, the carousel continues.
When the video is playing, when you slide to the next slide, the video will pause.

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:
  • JavaScript to achieve Taobao product image switching effect
  • javascript to realize product image magnifying glass
  • JavaScript implements product details of e-commerce platform

<<:  How to delete garbled or special character files in Linux

>>:  MySQL Order By Multi-Field Sorting Rules Code Example

Recommend

JavaScript implements an input box component

This article example shares the specific code for...

Nine advanced methods for deduplicating JS arrays (proven and effective)

Preface The general methods are not listed here, ...

How to store images in MySQL

1 Introduction When designing a database, it is i...

Raspberry Pi msmtp and mutt installation and configuration tutorial

1. Install mutt sudo apt-get install mutt 2. Inst...

A collection of information about forms and form submission operations in HTML

Here we introduce the knowledge about form elemen...

Six important selectors in CSS (remember them in three seconds)

From: https://blog.csdn.net/qq_44761243/article/d...

Analysis of GTK treeview principle and usage

The GtkTreeView component is an advanced componen...

Analysis of 2 Token Reasons and Sample Code in Web Project Development

Table of contents question: There are 2 tokens in...

CSS animation combined with SVG to create energy flow effect

The final effect is as follows: The animation is ...

Complete example of vue polling request solution

Understanding of polling In fact, the focus of po...

Introduction to scheduled tasks in Linux system

Table of contents 1. Customize plan tasks 2. Sync...

Share MySql8.0.19 installation pit record

The previous article introduced the installation ...