view360-canex
Version:
360 integrated viewing solution from inside-out view to outside-in view. It provides user-friendly service by rotating 360 degrees through various user interaction such as motion sensor and touch.
11 lines (10 loc) • 5.67 kB
JavaScript
/*
Copyright (c) 2017 NAVER Corp.
name: view360-canex
license: MIT
author: Canex
repository: https://github.com/Can-ExploreInc/egjs-view360
version: 3.4.9
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("@egjs/axes"),require("@egjs/agent")):"function"==typeof define&&define.amd?define(["@egjs/component","@egjs/axes","@egjs/agent"],e):((t="undefined"!=typeof globalThis?globalThis:t||self).eg=t.eg||{},t.eg.view360=e(t.eg.Component,t.eg.Axes,t.eg.agent))}(this,function(t,a,e){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function o(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var l=function(){return(l=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},r="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),i=r.document,e=e();e.os.name,e.browser.name;r.Float32Array=void 0!==r.Float32Array?r.Float32Array:r.Array;r.Float32Array,r.getComputedStyle,r.navigator.userAgent,r.DeviceMotionEvent,r.devicePixelRatio;var s=function(){for(var t=i.documentElement.style,e=["transform","webkitTransform","msTransform","mozTransform"],o=0,n=e.length;o<n;o++)if(e[o]in t)return e[o];return""}(),u=r.CSS&&r.CSS.supports&&r.CSS.supports("will-change","transform"),c="3.4.9",g=function(r){function i(t,e){void 0===e&&(e={});var o=r.call(this)||this,n=e||{};return o._el=t,o._rowCount=n.rowCount||1,o._colCount=n.colCount||1,o._totalCount=o._rowCount*o._colCount,o._width=n.width||"auto",o._height=n.height||"auto",o._autoHeight=null==n.autoHeight||n.autoHeight,o._colRow=[0,0],n.colRow?o._colRow=n.colRow:n.frameIndex&&o.setFrameIndex(n.frameIndex),o._el.style.width=i._getSizeString(o._width),o._el.style.height=i._getSizeString(o._height),n.imageUrl?(o._image=new Image,o._image.onload=function(){o._bg=i._createBgDiv(o._image,o._rowCount,o._colCount,o._autoHeight),o._el.appendChild(o._bg),o.setColRow(o._colRow[0],o._colRow[1]),o.trigger("load",{target:o._el,bgElement:o._bg}),o._autoPlayReservedInfo&&(o.play(o._autoPlayReservedInfo),o._autoPlayReservedInfo=null)},o._image.onerror=function(t){o.trigger("imageError",{imageUrl:n.imageUrl})},o._image.src=n.imageUrl):setTimeout(function(){o.trigger("imageError",{imageUrl:n.imageUrl})},0),o}o(i,r);var t=i.prototype;return i._createBgDiv=function(t,e,o,n){var r=document.createElement("div");r.style.position="relative",r.style.overflow="hidden",t.style.position="absolute",t.style.width=100*o+"%",t.style.height=100*e+"%",t.ondragstart=function(){return!1},u&&(t.style.willChange="transform"),r.appendChild(t);o=t.width/o,e=t.height/e;return n?(o=e/o,r.style.paddingBottom=100*o+"%"):r.style.height="100%",r},i._getSizeString=function(t){return"number"==typeof t?t+"px":t},t.setFrameIndex=function(t){t=this.toColRow(t);this.setColRow(t[0],t[1])},t.getFrameIndex=function(){return this._colRow[1]*this._colCount+this._colRow[0]},t.setColRow=function(t,e){e>this._rowCount-1||t>this._colCount-1||(this._image&&s&&(this._image.style[s]="translate("+-(t/this._colCount)*100+"%, "+-(e/this._rowCount)*100+"%)"),this._colRow=[t,e])},t.getColRow=function(){return this._colRow},t.stop=function(){this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=-1)},t.play=function(t){var e,o,n,r=this,i=void 0===t?{interval:1e3/this._totalCount,playCount:0}:t,t=i.interval,a=i.playCount;this._bg?(this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=-1),e=this.getFrameIndex(),n=o=0,this._autoPlayTimer=window.setInterval(function(){e%=r._totalCount;var t=r.toColRow(e);r.setColRow(t[0],t[1]),e++,++n===r._totalCount&&(n=0,o++),0<a&&o===a&&clearInterval(r._autoPlayTimer)},t)):this._autoPlayReservedInfo={interval:t,playCount:a}},t.toColRow=function(t){var e=this._colCount,o=this._rowCount;return t<0?[0,0]:t>=this._totalCount?[e-1,o-1]:[t%e,Math.floor(t/e)]},i.VERSION=c,i}(t);return{SpinViewer:function(i){function t(t,e){void 0===e&&(e={});var o=i.call(this)||this;o._el=t;var n=l({},e),r=n.colCount||1,e=n.rowCount||1;return o._scale=n.scale||1,o._panScale=.21*o._scale,o._frameCount=r*e,o._sprites=new g(t,n).on({load:function(t){o.trigger("load",t)},imageError:function(t){o.trigger("imageError",{imageUrl:t.imageUrl})}}),o._panInput=new a.PanInput(o._el,{scale:[o._panScale,o._panScale]}),o._axes=new a({angle:{range:[0,359],circular:!0}}).on({change:function(t){var e=Math.floor(t.pos.angle/(360/o._frameCount)),e=o._frameCount-e-1;o._sprites.setFrameIndex(e),o.trigger("change",{frameIndex:e,colRow:o._sprites.getColRow(),angle:t.pos.angle})},animationEnd:function(t){o.trigger("animationEnd",{isTrusted:t.isTrusted})}}),o._axes.connect("angle",o._panInput),o}o(t,i);var e=t.prototype;return e.setScale=function(t){return isNaN(t)||t<0||(this._scale=t,this._panScale=.21*t,this._panInput.options.scale=[this._panScale,this._panScale]),this},e.getScale=function(){return this._scale},e.spinBy=function(t,e){return void 0===t&&(t=0),void 0===e&&(e={duration:0}),this._axes.setBy({angle:t},e.duration),this},e.spinTo=function(t,e){return void 0===t&&(t=0),void 0===e&&(e={duration:0}),this._axes.setTo({angle:t},e.duration),this},e.getAngle=function(){return this._axes.get().angle||0},t.VERSION=c,t}(t),SpriteImage:g,VERSION:c}});
//# sourceMappingURL=view360.spinviewer.min.js.map