-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbootstrap-touch-slider.js
More file actions
executable file
·55 lines (44 loc) · 1.97 KB
/
bootstrap-touch-slider.js
File metadata and controls
executable file
·55 lines (44 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*Bootstrap Carousel Touch Slider.
http://bootstrapthemes.co
Credits: Bootstrap, jQuery, TouchSwipe, Animate.css, FontAwesome
*/
( function ( $ ) {
"use strict";
$.fn.bsTouchSlider = function ( options ) {
var carousel = $( ".carousel" );
return this.each( function ( ) {
function doAnimations( elems ) {
//Cache the animationend event in a variable
var animEndEv = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
elems.each( function ( ) {
var $this = $( this ),
$animationType = $this.data( 'animation' );
$this.addClass( $animationType ).one( animEndEv, function ( ) {
$this.removeClass( $animationType );
} );
} );
}
//Variables on page load
var $firstAnimatingElems = carousel.find( '.item:first' ).find( "[data-animation ^= 'animated']" );
//Initialize carousel
carousel.carousel( );
//Animate captions in first slide on page load
doAnimations( $firstAnimatingElems );
//Other slides to be animated on carousel slide event
carousel.on( 'slide.bs.carousel', function ( e ) {
var $animatingElems = $( e.relatedTarget ).find( "[data-animation ^= 'animated']" );
doAnimations( $animatingElems );
} );
//swipe initial
$( ".carousel .carousel-inner" ).swipe( {
swipeLeft: function ( event, direction, distance, duration, fingerCount ) {
this.parent( ).carousel( 'next' );
},
swipeRight: function ( ) {
this.parent( ).carousel( 'prev' );
},
threshold: 0
} );
} );
};
} )( jQuery );