timeline-events
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -1,1 +0,1 @@ | ||
var Timeline=function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){"use strict";e.r(n);var r=function(){return(r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)},i=function(t,n,e,r){return new(e||(e=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(a,s)}u((r=r.apply(t,n||[])).next())}))},o=function(t,n){var e,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;a;)try{if(e=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=n.call(t,a)}catch(t){o=[6,t],r=0}finally{e=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},a=function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var r=Array(t),i=0;for(n=0;n<e;n++)for(var o=arguments[n],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r},s=e(1),u=function(){function t(t){void 0===t&&(t=[]),this.state="stopped",this.manifest=t,this.progress=0,this.sequenceIndex=0,this.totalDuration=0,this.updateCb=null,this.finishedCb=null,this.timer={instance:null,duration:null,onInterval:null}}return t.prototype.play=function(t){return void 0===t&&(t=0),i(this,void 0,void 0,(function(){var n,e,r=this;return o(this,(function(i){switch(i.label){case 0:return[4,this.checkManifest("play")];case 1:return i.sent(),[4,this.stop()];case 2:return i.sent(),this.state="playing",this.manifest=this.provideIds(),this.progress=1e3*t,this.totalDuration=this.getDuration(),n=this.createCallbackList(this.organiseSequence(),t),e=Object.keys(n),this.initTimer({time:this.totalDuration,onInterval:function(t){for(var i=function(i){t>=Number(e[i])&&n[e[i]].length&&n[e[i]].forEach((function(o,a){o({stamp:t,progress:r.progress,percentage:r.getPercentage(r.progress)}),delete n[e[i]][a]}))},o=0;o<e.length;o++)i(o);r.updateCb&&r.updateCb({progress:r.progress,percentage:r.getPercentage(r.progress)})}}),[2]}}))}))},t.prototype.stop=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){return o(this,(function(n){return clearInterval(this.timer.instance),this.progress=0,this.state="stopped",t&&t({progress:this.progress,totalDuration:this.totalDuration}),[2]}))}))},t.prototype.pause=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){return o(this,(function(n){return"playing"!==this.state?(console.warn("Can't continue. Timeline is not in a playing state"),[2]):(clearInterval(this.timer.instance),this.state="paused",t&&t({progress:this.progress,totalDuration:this.totalDuration}),[2])}))}))},t.prototype.continue=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"paused"!==this.state?(console.warn("Can't continue. Timeline is not in a paused state"),[2]):[4,this.checkManifest("continue")];case 1:return t.sent(),this.initTimer({skipConfig:!0}),this.state="playing",[2]}}))}))},t.prototype.onUpdate=function(t){this.updateCb=t},t.prototype.finished=function(t){this.finishedCb=t},t.prototype.initTimer=function(t){var n=this;t.skipConfig||(this.timer.duration=t.time,this.timer.onInterval=t.onInterval),this.timer.onInterval(this.progress/1e3),this.timer.instance=setInterval((function(){if(n.progress+=10,n.timer.onInterval(n.progress/1e3),n.progress>n.timer.duration)return clearInterval(n.timer.instance),void(n.finishedCb&&n.finishedCb())}),10)},t.prototype.organiseSequence=function(){var t=[];return this.manifest.forEach((function(n,e){if("start"in n)t.push(r(r({},n),{start:n.start,id:n.id}));else{var i=t[e-1];t.push(r(r({},n),{start:n.followUp&&i?i.start+i.duration:0,id:n.id}))}})),t.sort((function(t,n){return t.start-n.start}))},t.prototype.provideIds=function(){return this.manifest.map((function(t){return r(r({},t),{id:s()})}))},t.prototype.createCallbackList=function(t,n){t=t.filter((function(t){return t.start>=n}));var e={};return t.forEach((function(t){var n=Math.round(100*(t.start+t.duration))/100,r=Math.round(100*t.start)/100;t.onStart&&(e[r]=a(e[r]||[],[t.onStart])),t.onEnd&&(e[n]=a(e[n]||[],[t.onEnd]))})),e},t.prototype.checkManifest=function(t){var n=this;return new Promise((function(e){if(!n.manifest.length)throw new Error("Cannot call function: "+t+", no valid manifest provided.");if(n.manifest.find((function(t){return!("start"in t||t.followUp)})))throw new Error("in event entries. Every entry should contain a 'start' or 'followUp' property.");if(n.manifest.find((function(t){return!t.duration})))throw new Error("in event entries. Duration property is required. Please check if all entries contain a duration property");e()}))},t.prototype.getDuration=function(){var t=this.organiseSequence().pop();return 1e3*(t.start+t.duration)},t.prototype.getPercentage=function(t){return Math.round(1e3-(t-this.totalDuration)/this.totalDuration*-1e3)/10},t}();n.default=u},function(t,n,e){var r=e(2),i=e(3);t.exports=function(t,n,e){var o=n&&e||0;"string"==typeof t&&(n="binary"===t?new Array(16):null,t=null);var a=(t=t||{}).random||(t.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n)for(var s=0;s<16;++s)n[o+s]=a[s];return n||i(a)}},function(t,n){var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var r=new Uint8Array(16);t.exports=function(){return e(r),r}}else{var i=new Array(16);t.exports=function(){for(var t,n=0;n<16;n++)0==(3&n)&&(t=4294967296*Math.random()),i[n]=t>>>((3&n)<<3)&255;return i}}},function(t,n){for(var e=[],r=0;r<256;++r)e[r]=(r+256).toString(16).substr(1);t.exports=function(t,n){var r=n||0,i=e;return[i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]]].join("")}}]); | ||
var Timeline=function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){"use strict";e.r(n);var r=function(){return(r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)},i=function(t,n,e,r){return new(e||(e=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(a,s)}u((r=r.apply(t,n||[])).next())}))},o=function(t,n){var e,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;a;)try{if(e=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=n.call(t,a)}catch(t){o=[6,t],r=0}finally{e=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},a=function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var r=Array(t),i=0;for(n=0;n<e;n++)for(var o=arguments[n],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r},s=e(1),u=function(){function t(t){void 0===t&&(t=[]),this.state="stopped",this.manifest=t,this.progress=0,this.sequenceIndex=0,this.totalDuration=0,this.updateCb=null,this.finishedCb=null,this.timer={instance:null,duration:null,onInterval:null}}return t.prototype.play=function(t){return void 0===t&&(t=0),i(this,void 0,void 0,(function(){var n,e,r=this;return o(this,(function(i){switch(i.label){case 0:return[4,this.checkManifest("play")];case 1:return i.sent(),[4,this.stop()];case 2:return i.sent(),this.state="playing",this.manifest=this.provideIds(),this.progress=1e3*t,this.totalDuration=this.getDuration(),n=this.createCallbackList(this.organiseSequence(),t),e=Object.keys(n),this.initTimer({time:this.totalDuration,onInterval:function(t){for(var i=function(i){t>=Number(e[i])&&n[e[i]].length&&n[e[i]].forEach((function(o,a){o({stamp:t,progress:r.progress,percentage:r.getPercentage(r.progress)}),delete n[e[i]][a]}))},o=0;o<e.length;o++)i(o);r.updateCb&&r.updateCb({progress:r.progress,percentage:r.getPercentage(r.progress)})}}),[2]}}))}))},t.prototype.stop=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){return o(this,(function(n){return clearInterval(this.timer.instance),this.progress=0,this.state="stopped",t&&t({progress:this.progress,totalDuration:this.totalDuration}),[2]}))}))},t.prototype.pause=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){return o(this,(function(n){return"playing"!==this.state?(console.warn("Can't continue. Timeline is not in a playing state"),[2]):(clearInterval(this.timer.instance),this.state="paused",t&&t({progress:this.progress,totalDuration:this.totalDuration}),[2])}))}))},t.prototype.continue=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"paused"!==this.state?(console.warn("Can't continue. Timeline is not in a paused state"),[2]):[4,this.checkManifest("continue")];case 1:return t.sent(),this.initTimer({skipConfig:!0}),this.state="playing",[2]}}))}))},t.prototype.onUpdate=function(t){this.updateCb=t},t.prototype.finished=function(t){this.finishedCb=t},t.prototype.initTimer=function(t){var n=this;t.skipConfig||(this.timer.duration=t.time,this.timer.onInterval=t.onInterval),this.timer.onInterval(this.progress/1e3),this.timer.instance=setInterval((function(){if(n.progress+=10,n.timer.onInterval(n.progress/1e3),n.progress>n.timer.duration)return clearInterval(n.timer.instance),void(n.finishedCb&&n.finishedCb())}),10)},t.prototype.organiseSequence=function(){var t=[];return this.manifest.forEach((function(n,e){if("start"in n)t.push(r(r({},n),{start:n.start,id:n.id}));else{var i=t[e-1];t.push(r(r({},n),{start:n.followUp&&i?i.start+i.duration:0,id:n.id}))}})),t.sort((function(t,n){return t.start-n.start}))},t.prototype.provideIds=function(){return this.manifest.map((function(t){return r(r({},t),{id:s()})}))},t.prototype.createCallbackList=function(t,n){t=t.filter((function(t){return t.start>=n}));var e={};return t.forEach((function(t){var n=Math.round(100*(t.start+t.duration))/100,r=Math.round(100*t.start)/100;t.onStart&&(e[r]=a(e[r]||[],[t.onStart])),t.onEnd&&(e[n]=a(e[n]||[],[t.onEnd]))})),e},t.prototype.checkManifest=function(t){var n=this;return new Promise((function(e){if(!n.manifest.length)throw new Error("Cannot call function: "+t+", no valid manifest provided.");if(n.manifest.find((function(t){return!("start"in t||t.followUp)})))throw new Error("in event entries. Every entry should contain a 'start' or 'followUp' property.");if(n.manifest.find((function(t){return!t.duration})))throw new Error("in event entries. Duration property is required. Please check if all entries contain a duration property");e()}))},t.prototype.getDuration=function(){var t=this.organiseSequence().pop();return 1e3*(t.start+t.duration)},t.prototype.getPercentage=function(t){return Math.round(1e3-(t-this.totalDuration)/this.totalDuration*-1e3)/10},t}();n.default=u},function(t,n,e){var r=e(2),i=e(3);t.exports=function(t,n,e){var o=n&&e||0;"string"==typeof t&&(n="binary"===t?new Array(16):null,t=null);var a=(t=t||{}).random||(t.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n)for(var s=0;s<16;++s)n[o+s]=a[s];return n||i(a)}},function(t,n){var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var r=new Uint8Array(16);t.exports=function(){return e(r),r}}else{var i=new Array(16);t.exports=function(){for(var t,n=0;n<16;n++)0==(3&n)&&(t=4294967296*Math.random()),i[n]=t>>>((3&n)<<3)&255;return i}}},function(t,n){for(var e=[],r=0;r<256;++r)e[r]=(r+256).toString(16).substr(1);t.exports=function(t,n){var r=n||0,i=e;return[i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]]].join("")}}]).default; |
{ | ||
"name": "timeline-events", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
24582