/*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 );