Вход Регистрация
Файл: CloudBox-main/doc/js/counters.js
Строк: 119
<?php
// JavaScript Document
(function($) {
    $.
fn.countTo = function(options) {
        
// merge the default plugin settings with the custom options
        
options = $.extend({}, $.fn.countTo.defaultsoptions || {});

        
// how many times to update the value, and how much to increment the value on each update
        
var loops Math.ceil(options.speed options.refreshInterval),
            
increment = (options.to options.from) / loops;

        return $(
this).each(function() {
            var 
_this this,
                
loopCount 0,
                
value options.from,
                
interval setInterval(updateTimeroptions.refreshInterval);

            function 
updateTimer() {
                
value += increment;
                
loopCount++;
                $(
_this).html(value.toFixed(options.decimals));

                if (
typeof(options.onUpdate) == 'function') {
                    
options.onUpdate.call(_thisvalue);
                }

                if (
loopCount >= loops) {
                    
clearInterval(interval);
                    
value options.to;

                    if (
typeof(options.onComplete) == 'function') {
                        
options.onComplete.call(_thisvalue);
                    }
                }
            }
        });
    };

            $.
fn.countTo.defaults = {
                
from0,  // the number the element should start at
                
to100,  // the number the element should end at
                
speed1000,  // how long it should take to count between the target numbers
                
refreshInterval100,  // how often the element should be updated
                
decimals0,  // the number of decimal places to show
                
onUpdatenull,  // callback method for every time the element is updated,
                
onCompletenull,  // callback method for when the element finishes updating
            
};
        })(
jQuery);
        
        
jQuery(function($) {
    
            $(
'#counters').waypoint(function(direction) {
                $(
'.timer1').countTo({
                    
from0,
                    
to120,
                    
speed1000,
                    
refreshInterval50,
                    
onComplete: function(value) {
                        
console.debug(this);
                    }
                });
                $(
'.timer2').countTo({
                    
visibletrue,
                    
from0,
                    
to161,
                    
speed1000,
                    
refreshInterval50,
                    
onComplete: function(value) {
                        
console.debug(this);
                    }
                });
                $(
'.timer3').countTo({
                    
from0,
                    
to13,
                    
speed1000,
                    
refreshInterval50,
                    
onComplete: function(value) {
                        
console.debug(this);
                    }
                });
                $(
'.timer4').countTo({
                    
from0,
                    
to212,
                    
speed1000,
                    
refreshInterval50,
                    
onComplete: function(value) {
                        
console.debug(this);
                    }
                });
                
                
                }, {
                
offset: function() {
                    return $.
waypoints('viewportHeight') - $(this).height() + 100;
                }
            });
        
        
    });
?>
Онлайн: 3
Реклама