Bootstrap 4 default carousel with swipe and touch gestures

Bootstrap 4 default carousel with swipe and touch gestures. The plugin add the swipes gesture to command the Bootstrap built in carousel on mobile and touch devices.


Plugin Overview

Plugin: bootstrap-4-carousel-with-swipe
Author: Andrea Rufo
Licence: MIT Licence
Published: March 19, 2019
Repository: Fork on CodePen
Dependencies: jQuery 1.3.1 or Latest version, Bootstrap 3.3.4 or Latest, Prefixfree 1.0.7 and TouchSwipe 1.6.4 or latest.
File Type: zip archive (HTML, CSS & JavaScript)
Package Size: 4 KB

How to Use it:

1. Load the Bootstrap framework, jQuery library, TouchSwipe (jQuery plugin) prefixfree Js into HTML document.

<!--Bootstrap CSS-->
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>

<!--Bootstrap JS-->
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js'></script>

<!--jQuery-->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

<!--Touch Swipe-->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.touchswipe/1.6.4/jquery.touchSwipe.min.js'></script>

<!--Prefixfree-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>

2. Create HTML structure for Bootstrap built-in Carousel like bellow and add your images links in it.

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
      <li data-target="#carousel-example-generic" data-slide-to="1"></li>
      <li data-target="#carousel-example-generic" data-slide-to="2"></li>
      <li data-target="#carousel-example-generic" data-slide-to="3"></li>
      <li data-target="#carousel-example-generic" data-slide-to="4"></li>
    </ol>
	
    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="https://unsplash.it/1400/600?girl">
      </div>
      <div class="item">
        <img src="https://unsplash.it/1400/600?bikni">
      </div>
      <div class="item">
        <img src="https://unsplash.it/1400/600?beauty">
      </div>
      <div class="item">
        <img src="https://unsplash.it/1400/600?cat">
      </div>
      <div class="item">
        <img src="https://unsplash.it/1400/600?natural">
      </div>
    </div>

    <!-- Controls -->
    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>

Be the first to comment

Leave a Reply

Your email address will not be published.


*