1/* Demo Scripts for Bootstrap Carousel and Animate.css article 2* on SitePoint by Maria Antonietta Perna 3*/ 4(function( $ ) { 5 6 //Function to animate slider captions 7 function doAnimations( elems ) { 8 //Cache the animationend event in a variable 9 var animEndEv = 'webkitAnimationEnd animationend'; 10 11 elems.each(function () { 12 var $this = $(this), 13 $animationType = $this.data('animation'); 14 $this.addClass($animationType).one(animEndEv, function () { 15 $this.removeClass($animationType); 16 }); 17 }); 18 } 19 20 //Variables on page load 21 var $myCarousel = $('#carousel-example-generic'), 22 $firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']"); 23 24 //Initialize carousel 25 $myCarousel.carousel(); 26 27 //Animate captions in first slide on page load 28 doAnimations($firstAnimatingElems); 29 30 //Pause carousel 31 $myCarousel.carousel('pause'); 32 33 34 //Other slides to be animated on carousel slide event 35 $myCarousel.on('slide.bs.carousel', function (e) { 36 var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']"); 37 doAnimations($animatingElems); 38 }); 39 40})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.