This time I will share jQuery Plugin and tutorial about Create Touch-enabled Bootstrap 4/3 Carousel With Swipe Carousel, hope it will help you in programming stack.
Swipe Carousel is a jQuery plugin to create mobile-friendly Bootstrap carousels by adding smart touch support to the native Bootstrap 4 or Bootstrap 3 carousel component.
With this plugin, the users are able to navigation between carousel slides by swiping on mobile devices.
How to use it:
1. Create a Bootstrap carousel on the page following the markup structure like this:
01 |
< div id = "carouselExampleIndicators" class = "carousel slide my-carousel" data-ride = "carousel" > |
02 |
< ol class = "carousel-indicators" > |
03 |
< li data-target = "#carouselExampleIndicators" data-slide-to = "0" class = "active" ></ li > |
04 |
< li data-target = "#carouselExampleIndicators" data-slide-to = "1" ></ li > |
05 |
< li data-target = "#carouselExampleIndicators" data-slide-to = "2" ></ li > |
07 |
< div class = "carousel-inner" > |
08 |
< div class = "carousel-item active" > |
11 |
< div class = "carousel-item" > |
14 |
< div class = "carousel-item" > |
18 |
< a class = "carousel-control-prev" href = "#carouselExampleIndicators" role = "button" data-slide = "prev" > |
19 |
< span class = "carousel-control-prev-icon" aria-hidden = "true" ></ span > |
20 |
< span class = "sr-only" >Previous</ span > |
22 |
< a class = "carousel-control-next" href = "#carouselExampleIndicators" role = "button" data-slide = "next" > |
23 |
< span class = "carousel-control-next-icon" aria-hidden = "true" ></ span > |
24 |
< span class = "sr-only" >Next</ span > |
2. Download and include the JavaScript file bootstrap-swipe-carousel.min.js
after Bootstrap JS.
1 |
< script src = "dist/bootstrap-swipe-carousel.min.js" ></ script > |
3. Initialize the Swipe Carousel plugin and done.
1 |
$( '.my-carousel' ).carousel().swipeCarousel({ |
4. Set the swipe sensitivity.
1 |
$( '.my-carousel' ).carousel().swipeCarousel({ |
5. You can also implement the Swipe Carousel as an ES6 module.
2 |
$ npm install swipe-carousel --save |
1 |
import $ from 'jquery' ; |
2 |
import bootstrap from 'bootstrap' ; |
3 |
import BootstrapSwipeCarousel from 'smart-bootstrap-swipe-carousel' ; |
Changelog:
2019-02-19
- Fix IOS issue with pointer events
This awesome jQuery plugin is developed by om/ardeshireshghi. For more Advanced Usages, please check the demo page or visit the official website.