-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 4.94 KB
/
index.js
1
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ticker",[],t):"object"==typeof exports?exports.ticker=t():n.ticker=t()}(window,function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)e.d(r,o,function(t){return n[t]}.bind(null,o));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";e.r(t);var r=function(){var n=[null,null,null],t=null,e=!1;function r(t,e){n[e]||(n[e]=[]),n[e].push(t)}function o(t,e){var r=n[e];r&&r.length>0&&(t(r),n[e]=null)}return{readAndExecute:function(i){return e=!0,function(t){for(var e=n.length,r=0;r<e;r++)o(t,r)}(i),e=!1,function(){var n=t?t.length:0;if(n>0)for(var e=0;e<n;e++){var o=t[e];r(o.func,o.level)}return t=null,0==n}()},reset:function(){e=!1,n=[null,null,null],t=[]},add:function(n,o){e?function(n,e){t||(t=[]),t.push({func:n,level:e})}(n,o):r(n,o)},isMemoryEmpty:function(){for(var t=n.length,e=0;e<t;e++){var r=n[e];if(r&&r.length>0)return!1}return!0}}}();var o=function(n){var t=0,e=0,o=n||100;function i(n){for(var t=0;t<n.length;t++){var e=n[t];e.call(e.this)}}function u(){++e<o?r.readAndExecute(i)?l():c():(console.warn("Animation frame loop executed to its set limit: ",o),l())}function c(){t=window?window.requestAnimationFrame(u):setTimeout(u)}function l(){e=0,r.reset(),window?window.cancelAnimationFrame(t):clearTimeout(t)}return function(n,t){r.isMemoryEmpty()&&c(),r.add(n,t)}}();var i=function n(){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.progressCallback,this.doneCallback,this.errorCallback};i.prototype.onError=function(n){return this.errorCallback=n,this},i.prototype.onProgress=function(n){return this.progressCallback=n,this},i.prototype.onDone=function(n){return this.doneCallback=n,this};var u="Maximum Loop Per Frame has to be a number",c="Start Index has to be a number",l="End Index has to be a number";function a(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function f(n){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function s(n){if(!n)throw new Error("Ticker: instance can't be null");if(!(n instanceof p)){var t=n.constructor?n.constructor.name:f(n);throw new Error("Ticker: Expecting instance of TickEntry got ".concat(t))}if(!n.func)throw new Error("Ticker: function can't be undefined")}var p=function(){function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.context=e,this.func=t,this.priority=r,this.executionCount=0,this.notifier=new i,s(this)}var t,e,r;return t=n,(e=[{key:"onDone",value:function(n){return this.notifier.doneCallback=n,this.notifier}},{key:"onError",value:function(n){return this.notifier.errorCallback=n,this.notifier}},{key:"dispose",value:function(){this.context=null,this.func=null,this.priority=null,this.executionCount=NaN,this.notifier=null}},{key:"executeInCycle",value:function(){s(this);var n=this,t=n.func,e=n.context,r=n.priority;return o(function(){var r=n.notifier,o=r.doneCallback,i=r.errorCallback;try{var u=t.call(e);n.executionCount++,o&&o(u)}catch(t){i?i(t):console.log(t),n.dispose()}},r),this.notifier.onProgress=void 0,this.notifier}},{key:"executeAsSmallLoopsInCycle",value:function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(void 0===n||"number"!=typeof n)throw new Error(u);if(void 0===t||"number"!=typeof t)throw new Error(l);if("number"!=typeof e)throw new Error(c);s(this);var r=this,i=r.func,a=r.context,f=r.priority,p=n,h=e;return o(function e(){for(var u,c=r.notifier,l=c.doneCallback,s=c.errorCallback,d=c.progressCallback;h<p;h++)try{u=i.call(a,h)}catch(n){return s&&s(n),void r.dispose()}p<t?(p+=n,d&&d(h,u),o(e,f)):h===t&&(r.executionCount++,l&&l(u))},f),this.notifier}}])&&a(t.prototype,e),r&&a(t,r),n}();p.HIGH=0,p.NORMAL=1,p.LOW=2,p.allowedTickCount=100;t.default=p}])});