function el_animate() { var delay, speed; jquery('.animated').each(function() { var el = jquery(this); //console.log( elements[i] , i ); if (el.visible(true)) { // checking if to animate for dial skills if(el.hasclass('countpercentage')){ //var element = jquery('.countpercentage'); //console.log(el.children('span')); var percentageto = el.data('percentageto'); var animdelay = el.data('animdelay'); animate_percentage(el.children('span'), percentageto, animdelay); } delay = el.data('animdelay'); if (!delay) { delay = 0; } el.css('-webkit-animation-delay', delay); el.css('-moz-animation-delay', delay); el.css('-o-animation-delay', delay); el.css('animation-delay', delay); speed = el.data('animspeed'); if (!speed) { speed = 0.5; } el.css('-webkit-animation-duration', speed); el.css('-moz-animation-duration', speed); el.css('-o-animation-duration', speed); el.css('animation-duration', speed); /*el.delay(1000) .queue( function(){ if (el.data('animtype')) { el.addclass(el.data('animtype')); } el.addclass('animated_visible'); });*/ if (el.data('animtype')) { el.addclass(el.data('animtype')); } el.addclass('animated_visible'); // que.push(this); } else if (el.data('animrepeat') == '1') { el.removeclass(el.data('animtype')); el.removeclass('animated_visible'); } }); } //jquery(window).ready(el_animate); //jquery(window).load(el_animate); jquery(window).scroll(function() { el_animate(); }); // animating percentage /* var element = jquery('.countpercentage'); var el = element.children('span'); var percentageto = jquery('.countpercentage').data('percentageto'); animate_percentage(el, percentageto, 15);*/ function animate_percentage( display , percent_to, speed){ var currentvalue = parseint(display.text()); var nextvalue = percent_to; var diff = nextvalue - currentvalue; var step = ( 0 < diff ? 1 : -1 ); for (var i = 0; i < math.abs(diff); ++i) { settimeout(function() { currentvalue += step; display.text(currentvalue); }, speed * i); } } /* * viewport - jquery selectors for finding elements in viewport * * copyright (c) 2008-2009 mika tuupola * * licensed under the mit license: * http://www.opensource.org/licenses/mit-license.php * * project home: * http://www.appelsiini.net/projects/viewport * */ (function($) { /** * copyright 2012, digital fusion * licensed under the mit license. * http://teamdf.com/jquery-plugins/license/ * * @author sam sehnert * @desc a small plugin that checks whether elements are within * the user visible viewport of a web browser. * only accounts for vertical position, not horizontal. */ $.fn.visible = function(partial) { var $t = $(this), $w = $(window), viewtop = $w.scrolltop(), viewbottom = viewtop + $w.height(), _top = $t.offset().top, _bottom = _top + $t.height(), comparetop = partial === true ? _bottom : _top, comparebottom = partial === true ? _top : _bottom; return ((comparebottom <= viewbottom) && (comparetop >= viewtop)); }; })(jquery);// javascript document