jquery - Add delay using .each when adding class -
i'm trying create simple animation in each letter scale 1 one. possible have 1 second delay when adding class in each div? here have done @ moment : jsfiddle
html
<div class="animation"> <div>a</div> <div>n</div> <div>i</div> <div>m</div> <div>a</div> <div>t</div> <div>e</div> </div>
css
.animate_letters{ float:left; text-transform:uppercase; font-size:80px; display:inline; margin-right:5px; animation:fancytext 1s cubic-bezier(0.3, 2, 0.35, 1.45) 0s normal none 1; } @keyframes fancytext{ { transform: scale(0) translatex(-40%); opacity:0; } { transform: scale(1) translatex(0%); opacity:1; } }
javascript
$(document).ready(function(){ $.each( $('.animation'), function(i, animation){ $('div', animation).each(function(){ $(this).addclass('animate_letters') }) }) })
you can use settimeout()
:
$(document).ready(function(){ $.each( $('.animation'), function(i, animation){ $('div', animation).each(function(ii){ var data = $(this); settimeout( function () { $(data).addclass('animate_letters') }, ii * 1000); })})});
update: dont need 2 .each()
. can narrow down 1 .each()
using selector $('.animation div')
:
$(document).ready(function(){ $('.animation div').each(function(ii){ var data = $(this); settimeout( function () { $(data).addclass('animate_letters') }, ii * 1000); })});
Comments
Post a Comment