/* * jquery.running.js - jquery plugin for running * * copyright (c) 2007-2015 qietu inc * * licensed under the mit license: * http://www.opensource.org/licenses/mit-license.php * * project home: * http://www.qietu.com/p/jquery.running.js * * version: 1.0.0 * */ (function ($) { $.fn.running = function () { function n() { var t = $(".animatenum"); var n = { top: $(window).scrolltop(), bottom: $(window).scrolltop() + $(window).height() }; t.each(function () { var t = $(this).attr("data-animatetarget"); n.top <= $(this).offset().top + $(this).height() && n.bottom >= $(this).offset().top && !$(this).data("start") && ($(this).data("start", !0), new animatenum({ obj: $(this), target: t, totaltime: 1e3 })) }) }; function b() { var t = $(".animatebar"); var n = { top: $(window).scrolltop(), bottom: $(window).scrolltop() + $(window).height() }; t.each(function () { var t = $(this).attr("data-animatetarget"); n.top <= $(this).offset().top + $(this).height() && n.bottom >= $(this).offset().top && !$(this).data("start") && ($(this).data("start", !0), new animatebar({ obj: $(this), target: t, totaltime: 1e3 })) }) }; function p() { var t = $(".animatepie"); var n = { top: $(window).scrolltop(), bottom: $(window).scrolltop() + $(window).height() }; t.each(function () { var t = $(this).attr("data-animatetarget"); n.top <= $(this).offset().top + $(this).height() && n.bottom >= $(this).offset().top && !$(this).data("start") && ($(this).data("start", !0), new animatepie({ obj: $(this), target: t, totaltime: 1e3 })) }) }; $(window).bind("scroll", function () { n(); b(); p() }); function animatenum(t) { this.obj = t.obj, this.target = t.target.tostring(), this.totaltime = t.totaltime || 1e3, this.init() }; function animatebar(t) { this.obj = t.obj, this.target = t.target.tostring(), this.totaltime = t.totaltime || 1e3, this.init() }; function animatepie(t) { this.obj = t.obj, this.target = t.target.tostring(), this.totaltime = t.totaltime || 1e3, this.init() }; animatenum.prototype = { init: function () { return this.target ? (this.animation(), void 0) : !1 }, animation: function () { var t = this, i = this.target.indexof("."), e = 0; i >= 0 && (e = this.target.length - i - 1); var n = this.target.replace(".", ""), s = this.totaltime / 30 | 0, a = n / s | 0, r = 0, h = 0; t.timer = setinterval(function () { r++ , h += a, t.obj.html(h / math.pow(10, e)), r >= s && (clearinterval(t.timer), t.obj.html(t.target)) }, 30) } }; animatebar.prototype = { init: function () { return this.target ? (this.animation(), void 0) : !1 }, animation: function () { var t = this, i = this.target.indexof("."), e = 0; i >= 0 && (e = this.target.length - i - 1); var n = this.target.replace(".", ""), s = this.totaltime / 30 | 0, a = n / s | 0, r = 0, h = 0; t.timer = setinterval(function () { r++ , h += a, t.obj.css('width', h / math.pow(10, e) + '%'), r >= s && (clearinterval(t.timer), t.obj.animate({ 'width': t.target + '%' })) }, 30) } }; animatepie.prototype = { init: function () { return this.target ? (this.animation(), void 0) : !1 }, animation: function () { var t = this; s = this.totaltime / 60 | 0; r = 0; t.i = 0; t.count = 0; t.j = 0; num = t.target; function start1() { t.obj.find('.pieinner span').html(t.i + 1); if (num == 0) return false; t.i = t.i + 1; if (t.i == num) { clearinterval(t.t1) } if (t.i == 50) { clearinterval(t.t1); num2 = num - 50; t.t2 = setinterval(start2, 1) }; t.obj.find(".pieleftinner").css("-o-transform", "rotate(" + t.i * 3.6 + "deg)"); t.obj.find(".pieleftinner").css("-moz-transform", "rotate(" + t.i * 3.6 + "deg)"); t.obj.find(".pieleftinner").css("-webkit-transform", "rotate(" + t.i * 3.6 + "deg)") }; function start2() { t.obj.find('.pieinner span').html(50 + t.j + 1); if (num2 == 0) return false; t.j = t.j + 1; if (t.j == num2) { clearinterval(t.t2) } if (t.j == 50) { clearinterval(t.t2) }; t.obj.find(".pierightinner").css("-o-transform", "rotate(" + t.j * 3.6 + "deg)"); t.obj.find(".pierightinner").css("-moz-transform", "rotate(" + t.j * 3.6 + "deg)"); t.obj.find(".pierightinner").css("-webkit-transform", "rotate(" + t.j * 3.6 + "deg)") }; t.t1 = setinterval(function () { r++; r >= s && (clearinterval(t.timer), start1()) }, 30) } } } })(jquery);