sso

bootstrap-touch-slider.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*Bootstrap Carousel Touch Slider.
  2. http://bootstrapthemes.co
  3. Credits: Bootstrap, jQuery, TouchSwipe, Animate.css, FontAwesome
  4. */
  5. ( function ( $ ) {
  6. "use strict";
  7. $.fn.bsTouchSlider = function ( options ) {
  8. var carousel = $( ".carousel" );
  9. return this.each( function ( ) {
  10. function doAnimations( elems ) {
  11. //Cache the animationend event in a variable
  12. var animEndEv = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
  13. elems.each( function ( ) {
  14. var $this = $( this ),
  15. $animationType = $this.data( 'animation' );
  16. $this.addClass( $animationType ).one( animEndEv, function ( ) {
  17. $this.removeClass( $animationType );
  18. } );
  19. } );
  20. }
  21. //Variables on page load
  22. var $firstAnimatingElems = carousel.find( '.item:first' ).find( "[data-animation ^= 'animated']" );
  23. //Initialize carousel
  24. carousel.carousel( );
  25. //Animate captions in first slide on page load
  26. doAnimations( $firstAnimatingElems );
  27. //Other slides to be animated on carousel slide event
  28. carousel.on( 'slide.bs.carousel', function ( e ) {
  29. var $animatingElems = $( e.relatedTarget ).find( "[data-animation ^= 'animated']" );
  30. doAnimations( $animatingElems );
  31. } );
  32. //swipe initial
  33. $( ".carousel .carousel-inner" ).swipe( {
  34. swipeLeft: function ( event, direction, distance, duration, fingerCount ) {
  35. this.parent( ).carousel( 'next' );
  36. },
  37. swipeRight: function ( ) {
  38. this.parent( ).carousel( 'prev' );
  39. },
  40. threshold: 0
  41. } );
  42. } );
  43. };
  44. } )( jQuery );