src/main/webapp/resources/assets2/js/progress-bar/number-pb.js

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

(function($) {
  var NumberProgressBar = function(element, options) {
    var settings = $.extend ({
      duration: 10000,
      style: 'basic',
      min: 0,
      max: 100,
      current: 0,
      shownQuery: '.number-pb-shown',
      numQuery: '.number-pb-num'
    }, options || {});

    this.duration = settings.duration;
    if (settings.style == 'percentage') {
      this.style = 'percentage';
      this.min   = 0;
      this.max   = 100;
    } else if (settings.style == 'step') {
      this.style = 'step';
      this.min   = 0;
      this.max   = (settings.max > this.min) ? settings.max : 100;
    } else {
      this.style = 'basic';
      if (settings.min < settings.max) {
        this.min = settings.min;
        this.max = settings.max;
      } else {
        this.min = 0;
        this.max = 100;
      }
    }
    this.current = (settings.current >= this.min && settings.current <= this.max) ? settings.current : this.min;
    this.interval = this.max - this.min;
    this.last = this.min;
    this.$element = $(element);
    this.$shownBar = this.$element.find(settings.shownQuery);
    this.$num = this.$element.find(settings.numQuery);

    this.reach(this.current);
  }

  NumberProgressBar.prototype.calDestination = function(dest) {
    return (dest < this.min) ? this.min : ( (dest > this.max) ? this.max : dest )
  }

  NumberProgressBar.prototype.calDuration = function() {
    return this.duration * Math.abs(this.current - this.last) / this.interval;
  }

  NumberProgressBar.prototype.shuffle = function(callback) {
    var dest = Math.round(Math.random() * this.interval) + this.min;
    this.reach(dest, null, callback);
  }

  NumberProgressBar.prototype.calPercentage = function() {
    return (this.current - this.min) / this.interval * 100
  }

  NumberProgressBar.prototype.numStyle = function(num) {
    var n = Math.ceil(num);
后面还有 76 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。