jquery-asPieProgress
Advanced tools
Comparing version 0.4.1 to 0.4.2
/** | ||
* jQuery asPieProgress v0.4.1 | ||
* jQuery asPieProgress v0.4.2 | ||
* https://github.com/amazingSurge/jquery-asPieProgress | ||
@@ -76,11 +76,11 @@ * | ||
let a = (aA1, aA2) => { | ||
const a = (aA1, aA2) => { | ||
return 1.0 - 3.0 * aA2 + 3.0 * aA1; | ||
}; | ||
let b = (aA1, aA2) => { | ||
const b = (aA1, aA2) => { | ||
return 3.0 * aA2 - 6.0 * aA1; | ||
}; | ||
let c = (aA1) => { | ||
const c = (aA1) => { | ||
return 3.0 * aA1; | ||
@@ -90,3 +90,3 @@ }; | ||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2. | ||
let calcBezier = (aT, aA1, aA2) => { | ||
const calcBezier = (aT, aA1, aA2) => { | ||
return ((a(aA1, aA2) * aT + b(aA1, aA2)) * aT + c(aA1)) * aT; | ||
@@ -96,7 +96,7 @@ }; | ||
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2. | ||
let getSlope = (aT, aA1, aA2) => { | ||
const getSlope = (aT, aA1, aA2) => { | ||
return 3.0 * a(aA1, aA2) * aT * aT + 2.0 * b(aA1, aA2) * aT + c(aA1); | ||
}; | ||
let getTForX = (aX) => { | ||
const getTForX = (aX) => { | ||
// Newton raphson iteration | ||
@@ -166,3 +166,3 @@ let aGuessT = aX; | ||
const NAME$1 = 'asPieProgress'; | ||
const NAMESPACE$1 = 'asPieProgress'; | ||
@@ -174,3 +174,3 @@ class asPieProgress { | ||
this.options = $.extend({}, DEFAULTS, {namespace: NAME$1}, options, this.$element.data()); | ||
this.options = $.extend({}, DEFAULTS, {namespace: NAMESPACE$1}, options, this.$element.data()); | ||
this.namespace = this.options.namespace; | ||
@@ -328,3 +328,3 @@ | ||
// event | ||
this.$element.trigger(`${NAME$1}::${eventType}`, data); | ||
this.$element.trigger(`${NAMESPACE$1}::${eventType}`, data); | ||
@@ -460,3 +460,3 @@ // callback | ||
destory() { | ||
this.$element.data(NAME$1, null); | ||
this.$element.data(NAMESPACE$1, null); | ||
this._trigger('destory'); | ||
@@ -479,9 +479,9 @@ } | ||
var info = { | ||
version:'0.4.1' | ||
version:'0.4.2' | ||
}; | ||
const NAME = 'asPieProgress'; | ||
const NAMESPACE = 'asPieProgress'; | ||
const OtherAsPieProgress = $.fn.asPieProgress; | ||
$.fn.asPieProgress = function jQueryAsPieProgress(options, ...args) { | ||
const jQueryAsPieProgress = function(options, ...args) { | ||
if (typeof options === 'string') { | ||
@@ -493,3 +493,3 @@ let method = options; | ||
} else if ((/^(get)/.test(method))) { | ||
let instance = this.first().data(NAME); | ||
let instance = this.first().data(NAMESPACE); | ||
if (instance && typeof instance[method] === 'function') { | ||
@@ -500,3 +500,3 @@ return instance[method](...args); | ||
return this.each(function() { | ||
let instance = $.data(this, NAME); | ||
let instance = $.data(this, NAMESPACE); | ||
if (instance && typeof instance[method] === 'function') { | ||
@@ -510,4 +510,4 @@ instance[method](...args); | ||
return this.each(function() { | ||
if (!$(this).data(NAME)) { | ||
$(this).data(NAME, new asPieProgress(this, options)); | ||
if (!$(this).data(NAMESPACE)) { | ||
$(this).data(NAMESPACE, new asPieProgress(this, options)); | ||
} | ||
@@ -517,2 +517,4 @@ }); | ||
$.fn.asPieProgress = jQueryAsPieProgress; | ||
$.asPieProgress = $.extend({ | ||
@@ -524,4 +526,4 @@ setDefaults: asPieProgress.setDefaults, | ||
$.fn.asPieProgress = OtherAsPieProgress; | ||
return this; | ||
return jQueryAsPieProgress; | ||
} | ||
}, info); |
/** | ||
* jQuery asPieProgress v0.4.1 | ||
* jQuery asPieProgress v0.4.2 | ||
* https://github.com/amazingSurge/jquery-asPieProgress | ||
@@ -250,3 +250,3 @@ * | ||
var NAME$1 = 'asPieProgress'; | ||
var NAMESPACE$1 = 'asPieProgress'; | ||
@@ -261,3 +261,3 @@ var asPieProgress = function() { | ||
this.options = _jquery2.default.extend({}, DEFAULTS, { | ||
namespace: NAME$1 | ||
namespace: NAMESPACE$1 | ||
}, options, this.$element.data()); | ||
@@ -433,3 +433,3 @@ this.namespace = this.options.namespace; | ||
// event | ||
this.$element.trigger(NAME$1 + '::' + eventType, data); | ||
this.$element.trigger(NAMESPACE$1 + '::' + eventType, data); | ||
@@ -586,3 +586,3 @@ // callback | ||
value: function destory() { | ||
this.$element.data(NAME$1, null); | ||
this.$element.data(NAMESPACE$1, null); | ||
this._trigger('destory'); | ||
@@ -615,9 +615,9 @@ } | ||
var info = { | ||
version: '0.4.1' | ||
version: '0.4.2' | ||
}; | ||
var NAME = 'asPieProgress'; | ||
var NAMESPACE = 'asPieProgress'; | ||
var OtherAsPieProgress = _jquery2.default.fn.asPieProgress; | ||
_jquery2.default.fn.asPieProgress = function jQueryAsPieProgress(options) { | ||
var jQueryAsPieProgress = function jQueryAsPieProgress(options) { | ||
var _this = this; | ||
@@ -639,3 +639,3 @@ | ||
} else if (/^(get)/.test(method)) { | ||
var instance = _this.first().data(NAME); | ||
var instance = _this.first().data(NAMESPACE); | ||
@@ -654,3 +654,3 @@ if (instance && typeof instance[method] === 'function') { | ||
function() { | ||
var instance = _jquery2.default.data(this, NAME); | ||
var instance = _jquery2.default.data(this, NAMESPACE); | ||
@@ -674,10 +674,11 @@ if (instance && typeof instance[method] === 'function') { | ||
function() { | ||
if (!(0, _jquery2.default)(this).data(NAME)) { | ||
(0, _jquery2.default)(this).data(NAME, new asPieProgress(this, options)); | ||
if (!(0, _jquery2.default)(this).data(NAMESPACE)) { | ||
(0, _jquery2.default)(this).data(NAMESPACE, new asPieProgress(this, options)); | ||
} | ||
} | ||
); | ||
} | ||
; | ||
}; | ||
_jquery2.default.fn.asPieProgress = jQueryAsPieProgress; | ||
_jquery2.default.asPieProgress = _jquery2.default.extend({ | ||
@@ -690,3 +691,3 @@ setDefaults: asPieProgress.setDefaults, | ||
return this; | ||
return jQueryAsPieProgress; | ||
} | ||
@@ -693,0 +694,0 @@ }, info); |
/** | ||
* jQuery asPieProgress v0.4.1 | ||
* jQuery asPieProgress v0.4.2 | ||
* https://github.com/amazingSurge/jquery-asPieProgress | ||
@@ -8,2 +8,2 @@ * | ||
*/ | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["jquery"],e);else if("undefined"!=typeof exports)e(require("jquery"));else{var i={exports:{}};e(t.jQuery),t.jqueryAsPieProgressEs=i.exports}}(this,function(t){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=e(t),s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);if(!e)return i;for(var n in e)Object.hasOwnProperty.call(e,n)&&i.setAttribute(n,e[n]);return i};Date.now||(Date.now=function(){return(new Date).getTime()});for(var o=["webkit","moz"],u=0;u<o.length&&!window.requestAnimationFrame;++u){var h=o[u];window.requestAnimationFrame=window[h+"RequestAnimationFrame"],window.cancelAnimationFrame=window[h+"CancelAnimationFrame"]||window[h+"CancelRequestAnimationFrame"]}!/iP(ad|hone|od).*OS (6|7)/.test(window.navigator.userAgent)&&window.requestAnimationFrame&&window.cancelAnimationFrame||!function(){var t=0;window.requestAnimationFrame=function(e){var i=l(),n=Math.max(t+16,i);return setTimeout(function(){e(t=n)},n-i)},window.cancelAnimationFrame=clearTimeout}();var l=function(){return"undefined"!=typeof window.performance&&window.performance.now?window.performance.now():Date.now()},f=function(t){return"string"==typeof t&&t.indexOf("%")!==-1},c="createElementNS"in document&&new a("svg",{}).createSVGRect,m=function(t,e,i,n){var s=function(t,e){return 1-3*e+3*t},r=function(t,e){return 3*e-6*t},a=function(t){return 3*t},o=function(t,e,i){return((s(e,i)*t+r(e,i))*t+a(e))*t},u=function(t,e,i){return 3*s(e,i)*t*t+2*r(e,i)*t+a(e)},h=function(e){for(var n=e,s=0;s<4;++s){var r=u(n,t,i);if(0===r)return n;var a=o(n,t,i)-e;n-=a/r}return n};return t===e&&i===n?{css:"linear",fn:function(t){return t}}:{css:"cubic-bezier("+t+","+e+","+i+","+n+")",fn:function(t){return o(h(t),e,n)}}},d={ease:m(.25,.1,.25,1),linear:m(0,0,1,1),"ease-in":m(.42,0,1,1),"ease-out":m(0,0,.58,1),"ease-in-out":m(.42,0,.58,1)},p={namespace:"",classes:{svg:"pie_progress__svg",element:"pie_progress",number:"pie_progress__number",content:"pie_progress__content"},min:0,max:100,goal:100,size:160,speed:15,barcolor:"#ef1e25",barsize:"4",trackcolor:"#f2f2f2",fillcolor:"none",easing:"ease",numberCallback:function(t){var e=Math.round(this.getPercentage(t));return e+"%"},contentCallback:null},g="asPieProgress",v=function(){function t(e,s){i(this,t),this.element=e,this.$element=(0,n.default)(e),this.options=n.default.extend({},p,{namespace:g},s,this.$element.data()),this.namespace=this.options.namespace,this.classes=this.options.classes,this.easing=d[this.options.easing]||d.ease,this.$element.addClass(this.classes.element),this.min=this.$element.attr("aria-valuemin"),this.max=this.$element.attr("aria-valuemax"),this.min=this.min?parseInt(this.min,10):this.options.min,this.max=this.max?parseInt(this.max,10):this.options.max,this.first=this.$element.attr("aria-valuenow"),this.first=this.first?parseInt(this.first,10):this.options.first?this.options.first:this.min,this.now=this.first,this.goal=this.options.goal,this._frameId=null,this.initialized=!1,this._trigger("init"),this.init()}return r(t,[{key:"init",value:function(){this.$number=this.$element.find("."+this.classes.number),this.$content=this.$element.find("."+this.classes.content),this.size=this.options.size,this.width=this.size,this.height=this.size,this.prepare(),this.initialized=!0,this._trigger("ready")}},{key:"prepare",value:function(){c&&(this.svg=new a("svg",{version:"1.1",preserveAspectRatio:"xMinYMin meet",viewBox:"0 0 "+this.width+" "+this.height}),this.buildTrack(),this.buildBar(),(0,n.default)('<div class="'+this.classes.svg+'"></div>').append(this.svg).appendTo(this.$element))}},{key:"buildTrack",value:function(){var t=this.size,e=this.size,i=e/2,n=t/2,s=this.options.barsize,r=new a("ellipse",{rx:i-s/2,ry:n-s/2,cx:i,cy:n,stroke:this.options.trackcolor,fill:this.options.fillcolor,"stroke-width":s});this.svg.appendChild(r)}},{key:"buildBar",value:function(){if(c){var t=new a("path",{fill:"none","stroke-width":this.options.barsize,stroke:this.options.barcolor});this.bar=t,this.svg.appendChild(t),this._drawBar(this.first),this._updateBar()}}},{key:"_drawBar",value:function(t){if(c){this.barGoal=t;var e=this.size,i=this.size,n=i/2,s=e/2,r=0,a=this.options.barsize,o=Math.min(n,s)-a/2;this.r=o;var u=this.getPercentage(t);100===u&&(u-=1e-4);var h=r+u*Math.PI*2/100,l=n+o*Math.sin(r),f=n+o*Math.sin(h),m=s-o*Math.cos(r),d=s-o*Math.cos(h),p=0;h-r>Math.PI&&(p=1);var g="M"+l+","+m+" A"+o+","+o+" 0 "+p+" 1 "+f+","+d;this.bar.setAttribute("d",g)}}},{key:"_updateBar",value:function(){if(c){var t=this.getPercentage(this.now),e=this.bar.getTotalLength(),i=e*(1-t/this.getPercentage(this.barGoal));this.bar.style.strokeDasharray=e+" "+e,this.bar.style.strokeDashoffset=i}}},{key:"_trigger",value:function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var s=[this].concat(i);this.$element.trigger(g+"::"+t,s),t=t.replace(/\b\w+\b/g,function(t){return t.substring(0,1).toUpperCase()+t.substring(1)});var r="on"+t;"function"==typeof this.options[r]&&this.options[r](i)}},{key:"getPercentage",value:function(t){return 100*(t-this.min)/(this.max-this.min)}},{key:"go",value:function(t){var e=this;this._clear(),f(t)&&(t=parseInt(t.replace("%",""),10),t=Math.round(this.min+t/100*(this.max-this.min))),"undefined"==typeof t&&(t=this.goal),t>this.max?t=this.max:t<this.min&&(t=this.min),this.barGoal<t&&this._drawBar(t);var i=e.now,n=l(),s=n+100*Math.abs(i-t)*e.options.speed/(e.max-e.min),r=function r(a){var o=void 0;if(a>s)o=t;else{var u=(a-n)/e.options.speed;o=Math.round(e.easing.fn(u/100)*(e.max-e.min)),t>i?(o=i+o,o>t&&(o=t)):(o=i-o,o<t&&(o=t))}e._update(o),o===t?(window.cancelAnimationFrame(e._frameId),e._frameId=null,e.now===e.goal&&e._trigger("finish")):e._frameId=window.requestAnimationFrame(r)};e._frameId=window.requestAnimationFrame(r)}},{key:"_update",value:function(t){this.now=t,this._updateBar(),this.$element.attr("aria-valuenow",this.now),this.$number.length>0&&"function"==typeof this.options.numberCallback&&this.$number.html(this.options.numberCallback.call(this,[this.now])),this.$content.length>0&&"function"==typeof this.options.contentCallback&&this.$content.html(this.options.contentCallback.call(this,[this.now])),this._trigger("update",t)}},{key:"_clear",value:function(){this._frameId&&(window.cancelAnimationFrame(this._frameId),this._frameId=null)}},{key:"get",value:function(){return this.now}},{key:"start",value:function(){this._clear(),this._trigger("start"),this.go(this.goal)}},{key:"reset",value:function(){this._clear(),this._drawBar(this.first),this._update(this.first),this._trigger("reset")}},{key:"stop",value:function(){this._clear(),this._trigger("stop")}},{key:"finish",value:function(){this._clear(),this._update(this.goal),this._trigger("finish")}},{key:"destory",value:function(){this.$element.data(g,null),this._trigger("destory")}}],[{key:"registerEasing",value:function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];d[t]=m.apply(void 0,i)}},{key:"getEasing",value:function(t){return d[t]}},{key:"setDefaults",value:function(t){n.default.extend(p,n.default.isPlainObject(t)&&t)}}]),t}(),w={version:"0.4.1"},y="asPieProgress",b=n.default.fn.asPieProgress;n.default.fn.asPieProgress=function(t){for(var e=this,i=arguments.length,r=Array(i>1?i-1:0),a=1;a<i;a++)r[a-1]=arguments[a];if("string"==typeof t){var o=function(){var i=t;if(/^_/.test(i))return{v:!1};if(!/^(get)/.test(i))return{v:e.each(function(){var t=n.default.data(this,y);t&&"function"==typeof t[i]&&t[i].apply(t,r)})};var s=e.first().data(y);return s&&"function"==typeof s[i]?{v:s[i].apply(s,r)}:void 0}();if("object"===("undefined"==typeof o?"undefined":s(o)))return o.v}return this.each(function(){(0,n.default)(this).data(y)||(0,n.default)(this).data(y,new v(this,t))})},n.default.asPieProgress=n.default.extend({setDefaults:v.setDefaults,registerEasing:v.registerEasing,getEasing:v.getEasing,noConflict:function(){return n.default.fn.asPieProgress=b,this}},w)}); | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["jquery"],e);else if("undefined"!=typeof exports)e(require("jquery"));else{var i={exports:{}};e(t.jQuery),t.jqueryAsPieProgressEs=i.exports}}(this,function(t){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=e(t),s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);if(!e)return i;for(var n in e)Object.hasOwnProperty.call(e,n)&&i.setAttribute(n,e[n]);return i};Date.now||(Date.now=function(){return(new Date).getTime()});for(var o=["webkit","moz"],u=0;u<o.length&&!window.requestAnimationFrame;++u){var h=o[u];window.requestAnimationFrame=window[h+"RequestAnimationFrame"],window.cancelAnimationFrame=window[h+"CancelAnimationFrame"]||window[h+"CancelRequestAnimationFrame"]}!/iP(ad|hone|od).*OS (6|7)/.test(window.navigator.userAgent)&&window.requestAnimationFrame&&window.cancelAnimationFrame||!function(){var t=0;window.requestAnimationFrame=function(e){var i=l(),n=Math.max(t+16,i);return setTimeout(function(){e(t=n)},n-i)},window.cancelAnimationFrame=clearTimeout}();var l=function(){return"undefined"!=typeof window.performance&&window.performance.now?window.performance.now():Date.now()},f=function(t){return"string"==typeof t&&t.indexOf("%")!==-1},c="createElementNS"in document&&new a("svg",{}).createSVGRect,m=function(t,e,i,n){var s=function(t,e){return 1-3*e+3*t},r=function(t,e){return 3*e-6*t},a=function(t){return 3*t},o=function(t,e,i){return((s(e,i)*t+r(e,i))*t+a(e))*t},u=function(t,e,i){return 3*s(e,i)*t*t+2*r(e,i)*t+a(e)},h=function(e){for(var n=e,s=0;s<4;++s){var r=u(n,t,i);if(0===r)return n;var a=o(n,t,i)-e;n-=a/r}return n};return t===e&&i===n?{css:"linear",fn:function(t){return t}}:{css:"cubic-bezier("+t+","+e+","+i+","+n+")",fn:function(t){return o(h(t),e,n)}}},d={ease:m(.25,.1,.25,1),linear:m(0,0,1,1),"ease-in":m(.42,0,1,1),"ease-out":m(0,0,.58,1),"ease-in-out":m(.42,0,.58,1)},p={namespace:"",classes:{svg:"pie_progress__svg",element:"pie_progress",number:"pie_progress__number",content:"pie_progress__content"},min:0,max:100,goal:100,size:160,speed:15,barcolor:"#ef1e25",barsize:"4",trackcolor:"#f2f2f2",fillcolor:"none",easing:"ease",numberCallback:function(t){var e=Math.round(this.getPercentage(t));return e+"%"},contentCallback:null},g="asPieProgress",v=function(){function t(e,s){i(this,t),this.element=e,this.$element=(0,n.default)(e),this.options=n.default.extend({},p,{namespace:g},s,this.$element.data()),this.namespace=this.options.namespace,this.classes=this.options.classes,this.easing=d[this.options.easing]||d.ease,this.$element.addClass(this.classes.element),this.min=this.$element.attr("aria-valuemin"),this.max=this.$element.attr("aria-valuemax"),this.min=this.min?parseInt(this.min,10):this.options.min,this.max=this.max?parseInt(this.max,10):this.options.max,this.first=this.$element.attr("aria-valuenow"),this.first=this.first?parseInt(this.first,10):this.options.first?this.options.first:this.min,this.now=this.first,this.goal=this.options.goal,this._frameId=null,this.initialized=!1,this._trigger("init"),this.init()}return r(t,[{key:"init",value:function(){this.$number=this.$element.find("."+this.classes.number),this.$content=this.$element.find("."+this.classes.content),this.size=this.options.size,this.width=this.size,this.height=this.size,this.prepare(),this.initialized=!0,this._trigger("ready")}},{key:"prepare",value:function(){c&&(this.svg=new a("svg",{version:"1.1",preserveAspectRatio:"xMinYMin meet",viewBox:"0 0 "+this.width+" "+this.height}),this.buildTrack(),this.buildBar(),(0,n.default)('<div class="'+this.classes.svg+'"></div>').append(this.svg).appendTo(this.$element))}},{key:"buildTrack",value:function(){var t=this.size,e=this.size,i=e/2,n=t/2,s=this.options.barsize,r=new a("ellipse",{rx:i-s/2,ry:n-s/2,cx:i,cy:n,stroke:this.options.trackcolor,fill:this.options.fillcolor,"stroke-width":s});this.svg.appendChild(r)}},{key:"buildBar",value:function(){if(c){var t=new a("path",{fill:"none","stroke-width":this.options.barsize,stroke:this.options.barcolor});this.bar=t,this.svg.appendChild(t),this._drawBar(this.first),this._updateBar()}}},{key:"_drawBar",value:function(t){if(c){this.barGoal=t;var e=this.size,i=this.size,n=i/2,s=e/2,r=0,a=this.options.barsize,o=Math.min(n,s)-a/2;this.r=o;var u=this.getPercentage(t);100===u&&(u-=1e-4);var h=r+u*Math.PI*2/100,l=n+o*Math.sin(r),f=n+o*Math.sin(h),m=s-o*Math.cos(r),d=s-o*Math.cos(h),p=0;h-r>Math.PI&&(p=1);var g="M"+l+","+m+" A"+o+","+o+" 0 "+p+" 1 "+f+","+d;this.bar.setAttribute("d",g)}}},{key:"_updateBar",value:function(){if(c){var t=this.getPercentage(this.now),e=this.bar.getTotalLength(),i=e*(1-t/this.getPercentage(this.barGoal));this.bar.style.strokeDasharray=e+" "+e,this.bar.style.strokeDashoffset=i}}},{key:"_trigger",value:function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var s=[this].concat(i);this.$element.trigger(g+"::"+t,s),t=t.replace(/\b\w+\b/g,function(t){return t.substring(0,1).toUpperCase()+t.substring(1)});var r="on"+t;"function"==typeof this.options[r]&&this.options[r](i)}},{key:"getPercentage",value:function(t){return 100*(t-this.min)/(this.max-this.min)}},{key:"go",value:function(t){var e=this;this._clear(),f(t)&&(t=parseInt(t.replace("%",""),10),t=Math.round(this.min+t/100*(this.max-this.min))),"undefined"==typeof t&&(t=this.goal),t>this.max?t=this.max:t<this.min&&(t=this.min),this.barGoal<t&&this._drawBar(t);var i=e.now,n=l(),s=n+100*Math.abs(i-t)*e.options.speed/(e.max-e.min),r=function r(a){var o=void 0;if(a>s)o=t;else{var u=(a-n)/e.options.speed;o=Math.round(e.easing.fn(u/100)*(e.max-e.min)),t>i?(o=i+o,o>t&&(o=t)):(o=i-o,o<t&&(o=t))}e._update(o),o===t?(window.cancelAnimationFrame(e._frameId),e._frameId=null,e.now===e.goal&&e._trigger("finish")):e._frameId=window.requestAnimationFrame(r)};e._frameId=window.requestAnimationFrame(r)}},{key:"_update",value:function(t){this.now=t,this._updateBar(),this.$element.attr("aria-valuenow",this.now),this.$number.length>0&&"function"==typeof this.options.numberCallback&&this.$number.html(this.options.numberCallback.call(this,[this.now])),this.$content.length>0&&"function"==typeof this.options.contentCallback&&this.$content.html(this.options.contentCallback.call(this,[this.now])),this._trigger("update",t)}},{key:"_clear",value:function(){this._frameId&&(window.cancelAnimationFrame(this._frameId),this._frameId=null)}},{key:"get",value:function(){return this.now}},{key:"start",value:function(){this._clear(),this._trigger("start"),this.go(this.goal)}},{key:"reset",value:function(){this._clear(),this._drawBar(this.first),this._update(this.first),this._trigger("reset")}},{key:"stop",value:function(){this._clear(),this._trigger("stop")}},{key:"finish",value:function(){this._clear(),this._update(this.goal),this._trigger("finish")}},{key:"destory",value:function(){this.$element.data(g,null),this._trigger("destory")}}],[{key:"registerEasing",value:function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];d[t]=m.apply(void 0,i)}},{key:"getEasing",value:function(t){return d[t]}},{key:"setDefaults",value:function(t){n.default.extend(p,n.default.isPlainObject(t)&&t)}}]),t}(),w={version:"0.4.2"},y="asPieProgress",b=n.default.fn.asPieProgress,_=function(t){for(var e=this,i=arguments.length,r=Array(i>1?i-1:0),a=1;a<i;a++)r[a-1]=arguments[a];if("string"==typeof t){var o=function(){var i=t;if(/^_/.test(i))return{v:!1};if(!/^(get)/.test(i))return{v:e.each(function(){var t=n.default.data(this,y);t&&"function"==typeof t[i]&&t[i].apply(t,r)})};var s=e.first().data(y);return s&&"function"==typeof s[i]?{v:s[i].apply(s,r)}:void 0}();if("object"===("undefined"==typeof o?"undefined":s(o)))return o.v}return this.each(function(){(0,n.default)(this).data(y)||(0,n.default)(this).data(y,new v(this,t))})};n.default.fn.asPieProgress=_,n.default.asPieProgress=n.default.extend({setDefaults:v.setDefaults,registerEasing:v.registerEasing,getEasing:v.getEasing,noConflict:function(){return n.default.fn.asPieProgress=b,_}},w)}); |
@@ -5,3 +5,3 @@ { | ||
"description": "A jQuery plugin that animate the pie progress.", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"homepage": "https://github.com/amazingSurge/jquery-asPieProgress", | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -8,3 +8,3 @@ import $ from 'jquery'; | ||
const NAME = 'asPieProgress'; | ||
const NAMESPACE = 'asPieProgress'; | ||
@@ -16,3 +16,3 @@ class asPieProgress { | ||
this.options = $.extend({}, DEFAULTS, {namespace: NAME}, options, this.$element.data()); | ||
this.options = $.extend({}, DEFAULTS, {namespace: NAMESPACE}, options, this.$element.data()); | ||
this.namespace = this.options.namespace; | ||
@@ -170,3 +170,3 @@ | ||
// event | ||
this.$element.trigger(`${NAME}::${eventType}`, data); | ||
this.$element.trigger(`${NAMESPACE}::${eventType}`, data); | ||
@@ -302,3 +302,3 @@ // callback | ||
destory() { | ||
this.$element.data(NAME, null); | ||
this.$element.data(NAMESPACE, null); | ||
this._trigger('destory'); | ||
@@ -305,0 +305,0 @@ } |
const easingBezier = (mX1, mY1, mX2, mY2) => { | ||
'use strict'; | ||
let a = (aA1, aA2) => { | ||
const a = (aA1, aA2) => { | ||
return 1.0 - 3.0 * aA2 + 3.0 * aA1; | ||
}; | ||
let b = (aA1, aA2) => { | ||
const b = (aA1, aA2) => { | ||
return 3.0 * aA2 - 6.0 * aA1; | ||
}; | ||
let c = (aA1) => { | ||
const c = (aA1) => { | ||
return 3.0 * aA1; | ||
@@ -17,3 +17,3 @@ }; | ||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2. | ||
let calcBezier = (aT, aA1, aA2) => { | ||
const calcBezier = (aT, aA1, aA2) => { | ||
return ((a(aA1, aA2) * aT + b(aA1, aA2)) * aT + c(aA1)) * aT; | ||
@@ -23,7 +23,7 @@ }; | ||
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2. | ||
let getSlope = (aT, aA1, aA2) => { | ||
const getSlope = (aT, aA1, aA2) => { | ||
return 3.0 * a(aA1, aA2) * aT * aT + 2.0 * b(aA1, aA2) * aT + c(aA1); | ||
}; | ||
let getTForX = (aX) => { | ||
const getTForX = (aX) => { | ||
// Newton raphson iteration | ||
@@ -30,0 +30,0 @@ let aGuessT = aX; |
export default { | ||
version:'0.4.1' | ||
version:'0.4.2' | ||
}; |
@@ -5,6 +5,6 @@ import $ from 'jquery'; | ||
const NAME = 'asPieProgress'; | ||
const NAMESPACE = 'asPieProgress'; | ||
const OtherAsPieProgress = $.fn.asPieProgress; | ||
$.fn.asPieProgress = function jQueryAsPieProgress(options, ...args) { | ||
const jQueryAsPieProgress = function(options, ...args) { | ||
if (typeof options === 'string') { | ||
@@ -16,3 +16,3 @@ let method = options; | ||
} else if ((/^(get)/.test(method))) { | ||
let instance = this.first().data(NAME); | ||
let instance = this.first().data(NAMESPACE); | ||
if (instance && typeof instance[method] === 'function') { | ||
@@ -23,3 +23,3 @@ return instance[method](...args); | ||
return this.each(function() { | ||
let instance = $.data(this, NAME); | ||
let instance = $.data(this, NAMESPACE); | ||
if (instance && typeof instance[method] === 'function') { | ||
@@ -33,4 +33,4 @@ instance[method](...args); | ||
return this.each(function() { | ||
if (!$(this).data(NAME)) { | ||
$(this).data(NAME, new asPieProgress(this, options)); | ||
if (!$(this).data(NAMESPACE)) { | ||
$(this).data(NAMESPACE, new asPieProgress(this, options)); | ||
} | ||
@@ -40,2 +40,4 @@ }); | ||
$.fn.asPieProgress = jQueryAsPieProgress; | ||
$.asPieProgress = $.extend({ | ||
@@ -47,4 +49,4 @@ setDefaults: asPieProgress.setDefaults, | ||
$.fn.asPieProgress = OtherAsPieProgress; | ||
return this; | ||
return jQueryAsPieProgress; | ||
} | ||
}, info); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74145
1458