Forked from Amruth Pillai's Pen jQuery Text Rotator.
A Pen by Captain Anonymous on CodePen.
<h1> I am | |
<div id="rotate"> | |
<div>awesome.</div> | |
<div>invincible.</div> | |
<div>unbeatable.</div> | |
<div>indestructible.</div> | |
</div> | |
</h1> |
$(document).ready(function() { | |
$('#rotate').rotaterator({fadeSpeed:200, pauseSpeed:7500}); | |
}); |
Forked from Amruth Pillai's Pen jQuery Text Rotator.
A Pen by Captain Anonymous on CodePen.
(function($){ | |
$.fn.extend({ | |
rotaterator: function(options) { | |
var defaults = { | |
fadeSpeed: 100, | |
pauseSpeed: 1000 | |
, | |
child:null | |
}; | |
var options = $.extend(defaults, options); | |
return this.each(function() { | |
var o =options; | |
var obj = $(this); | |
var items = $(obj.children(), obj); | |
items.each(function() {$(this).hide();}) | |
if(!o.child){var next = $(obj).children(':first'); | |
}else{var next = o.child; | |
} | |
$(next).fadeIn(o.fadeSpeed, function() { | |
$(next).delay(o.pauseSpeed).fadeOut(o.fadeSpeed, function() { | |
var next = $(this).next(); | |
if (next.length == 0){ | |
next = $(obj).children(':first'); | |
} | |
$(obj).rotaterator({child : next, fadeSpeed : o.fadeSpeed, pauseSpeed : o.pauseSpeed}); | |
}) | |
}); | |
}); | |
} | |
}); | |
})(jQuery); |
!function(e){e.fn.extend({rotaterator:function(d){var t={fadeSpeed:100,pauseSpeed:1e3,child:null},d=e.extend(t,d);return this.each(function(){var t=d,n=e(this);if(e(n.children(),n).each(function(){e(this).hide()}),t.child)a=t.child;else var a=e(n).children(":first");e(a).fadeIn(t.fadeSpeed,function(){e(a).delay(t.pauseSpeed).fadeOut(t.fadeSpeed,function(){var d=e(this).next();0==d.length&&(d=e(n).children(":first")),e(n).rotaterator({child:d,fadeSpeed:t.fadeSpeed,pauseSpeed:t.pauseSpeed})})})})}})}(jQuery); |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |