@lumiscaphe/viewer
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.viewer=e()}(this,function(){"use strict";!function(){function t(t){this.value=t}function e(e){function n(t,e){return new Promise(function(n,o){var s={key:t,arg:e,resolve:n,reject:o,next:null};a?a=a.next=s:(r=a=s,i(t,e))})}function i(n,r){try{var a=e[n](r),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){i("next",t)},function(t){i("throw",t)}):o(a.done?"return":"normal",a.value)}catch(t){o("throw",t)}}function o(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?i(r.key,r.arg):a=null}var r,a;this._invoke=n,"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},e=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),n=function(){function n(){t(this,n)}return e(n,null,[{key:"getAutoResolution",value:function(t){var e=t.offsetWidth,i=t.offsetHeight;if(0===e||0===i)return{width:0,height:0};var o=n.getStandardAspectRatio(e,i);if(e>i){var r=null;return r=e<=240*o?240*o:e<=360*o?360*o:e<=480*o?480*o:e<=720*o?720*o:1080*o,{width:Math.round(r),height:Math.round(r/o)}}var a=null;return a=i<=240?240:i<=360?360:i<=480?480:i<=720?720:1080,{width:Math.round(a*o),height:Math.round(a)}}},{key:"getStandardAspectRatio",value:function(t,e){var n=t/e;return n>4/3?n=16/9:n<=4/3&&(n=4/3),n}}]),n}();return function(){function i(e,n){var o=this;t(this,i),this.container=e,this.container.style.display="flex",this.container.style.overflow="hidden",this.container.style.width="100%",this.container.style.height="100%",this.canvas=document.createElement("canvas"),this.canvas.style.flex=1,this.canvas.style["object-fit"]="cover",this.canvas.style.width="100%",this.canvas.style.height="100%",this.container.appendChild(this.canvas),this.context=this.canvas.getContext("2d"),this.options=n,this.params=null,this.requestAnimationId=null,window.addEventListener("resize",function(){o.resize()}),this.resize()}return e(i,[{key:"resize",value:function(){this.resolution=n.getAutoResolution(this.container),this.canvas.width=this.resolution.width,this.canvas.height=this.resolution.height,this.load(this.params)}},{key:"load",value:function(t){var e=this;if(null!==t&&0!==this.resolution.width&&0!==this.resolution.height){this.params=t,t.width=this.resolution.width,t.height=this.resolution.height;var n=Object.keys(t).map(function(e){return e+"="+t[e]}).join("&"),i=this.options.webrender+"/ImageFromBookmark?"+n,o=new Image;o.addEventListener("load",function(){e.fadein(o)}),o.src=i}}},{key:"fadein",value:function(t){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),this.context.globalAlpha=0,this.fadeloop(t)}},{key:"fadeloop",value:function(t){var e=this;if(this.context.globalAlpha>1)return void(this.requestAnimationId=null);this.context.globalAlpha+=.01,this.context.drawImage(t,0,0,this.canvas.width,this.canvas.height),this.requestAnimationId=requestAnimationFrame(function(){e.fadeloop(t)})}}]),i}()}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.viewer=e()}(this,function(){"use strict";!function(){function t(t){this.value=t}function e(e){function n(t,e){return new Promise(function(n,o){var s={key:t,arg:e,resolve:n,reject:o,next:null};r?r=r.next=s:(a=r=s,i(t,e))})}function i(n,a){try{var r=e[n](a),s=r.value;s instanceof t?Promise.resolve(s.value).then(function(t){i("next",t)},function(t){i("throw",t)}):o(r.done?"return":"normal",r.value)}catch(t){o("throw",t)}}function o(t,e){switch(t){case"return":a.resolve({value:e,done:!0});break;case"throw":a.reject(e);break;default:a.resolve({value:e,done:!1})}(a=a.next)?i(a.key,a.arg):r=null}var a,r;this._invoke=n,"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},e=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),n=function(){function n(){t(this,n)}return e(n,null,[{key:"fit",value:function(t,e,n,i){var o=t.width/t.height,a=e/n,r=0,s=0;switch(i){case"contain":r=a<o?e:n*o,s=a<o?e/o:n;break;case"cover":r=a<o?n*o:e,s=a<o?n:e/o;break;case"fill":r=e,s=n}return{width:Math.round(r),height:Math.round(s),top:Math.round((n-s)/2),left:Math.round((e-r)/2)}}},{key:"getStandardQuality",value:function(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080}},{key:"getStandardResolution",value:function(t,e){if(0===t||0===e)return{width:0,height:0};var i=0,o=0;return t>e?(i=t/e>4/3?16/9:4/3,o=n.getStandardQuality(t/i),{width:Math.round(o*i),height:Math.round(o)}):(i=t/e<.75?9/16:.75,o=n.getStandardQuality(e*i),{width:Math.round(o),height:Math.round(o/i)})}}]),n}();return function(){function i(e,n){var o=this;t(this,i),this.container=e,this.container.style.position="relative",this.container.style.overflow="hidden",this.container.style.width="100%",this.container.style.height="100%",this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.context=this.canvas.getContext("2d"),this.container.appendChild(this.canvas),this.options=n,this.params=null,this.requestAnimationId=null,this.resolution={},window.addEventListener("resize",function(){o.resize(),o.load(o.params,!0)}),this.resize()}return e(i,[{key:"resize",value:function(){var t=this.container.offsetWidth,e=this.container.offsetHeight,i=n.getStandardResolution(t,e),o=n.fit(i,t,e,"cover");this.canvas.style.width=o.width+"px",this.canvas.style.height=o.height+"px",this.canvas.style.top=o.top+"px",this.canvas.style.left=o.left+"px",i.width===this.resolution.width&&i.height==this.resolution.height||(this.canvas.width=i.width,this.canvas.height=i.height,this.resolution=i)}},{key:"load",value:function(t,e){var n=this;if(null!==t&&(this.params=t,0!==this.resolution.width&&0!==this.resolution.height)){t.width=this.resolution.width,t.height=this.resolution.height;var i=Object.keys(t).map(function(e){return e+"="+t[e]}).join("&"),o=this.options.server+"/ImageFromBookmark?"+i,a=new Image;a.addEventListener("load",function(){e?n.draw(a):n.fadeIn(a)}),a.src=o}}},{key:"draw",value:function(t){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),this.context.drawImage(t,0,0,this.canvas.width,this.canvas.height)}},{key:"fadeIn",value:function(t){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=null),this.context.globalAlpha=0,this.fadeInLoop(t)}},{key:"fadeInLoop",value:function(t){var e=this;if(this.context.globalAlpha>1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=null);this.context.globalAlpha+=.01,this.context.drawImage(t,0,0,this.canvas.width,this.canvas.height),this.requestAnimationId=requestAnimationFrame(function(){e.fadeInLoop(t)})}}]),i}()}); |
{ | ||
"name": "@lumiscaphe/viewer", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Lumiscaphe 3D Viewer", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-commonjs": "^8.2.4", | ||
"rollup-plugin-commonjs": "^8.2.5", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
@@ -21,0 +21,0 @@ "rollup-plugin-uglify-es": "^0.0.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5153
17