@egjs/view360
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.
10 lines (9 loc) • 5.68 kB
JavaScript
/*
Copyright (c) 2017 NAVER Corp.
@egjs/view360 project is licensed under the MIT license
@egjs/view360 JavaScript library
https://github.com/naver/egjs-view360
@version 3.2.2-rc
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@egjs/axes"),require("@egjs/component")):"function"==typeof define&&define.amd?define(["exports","@egjs/axes","@egjs/component"],e):e((t.eg=t.eg||{},t.eg.view360={}),t.eg.Axes,t.eg.Component)}(this,function(t,l,e){"use strict";function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}function o(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}var n="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),r=n.document,i=n.navigator.userAgent;-1!==i.indexOf("Safari")&&-1===i.indexOf("Chrome")&&i.indexOf("Mac OS X");n.Float32Array=void 0!==n.Float32Array?n.Float32Array:n.Array;n.Float32Array,n.getComputedStyle,n.navigator.userAgent,n.DeviceMotionEvent,n.devicePixelRatio;var a=function(){for(var t=r.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=n.CSS&&n.CSS.supports&&n.CSS.supports("will-change","transform"),c="3.2.2-rc",g=function(){var t=function(r){function i(t,e){var o;o=r.call(this)||this;var 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:"true",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,o):(setTimeout(function(){o.trigger("imageError",{imageUrl:n.imageUrl})},0),function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(o))}o(i,r),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);var i=t.width/o,a=t.height/e;if(n){var l=a/i;r.style.paddingBottom=100*l+"%"}else r.style.height="100%";return r};var t=i.prototype;return t.setFrameIndex=function(t){var e=this.toColRow(t);this.setColRow(e[0],e[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&&a&&(this._image.style[a]="translate("+-t/this._colCount*100+"%, "+-e/this._rowCount*100+"%)"),this._colRow=[t,e])},t.getColRow=function(){return this._colRow},i._getSizeString=function(t){return"number"==typeof t?t+"px":t},t.stop=function(){this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=null)},t.play=function(t){var e=this,o=void 0===t?{interval:1e3/this._totalCount,playCount:0}:t,n=o.interval,r=o.playCount;if(this._bg){this._autoPlayTimer&&(clearInterval(this._autoPlayTimer),this._autoPlayTimer=null);var i=this.getFrameIndex(),a=0,l=0;this._autoPlayTimer=setInterval(function(){i%=e._totalCount;var t=e.toColRow(i);e.setColRow(t[0],t[1]),i++,++l===e._totalCount&&(l=0,a++),0<r&&a===r&&clearInterval(e._autoPlayTimer)},n)}else this._autoPlayReservedInfo={interval:n,playCount:r}},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}(e);return t.VERSION=c,t}(),_=function(){var t=function(a){function t(t,e){var n;(n=a.call(this)||this)._el=t;var o=s({},e),r=o.colCount||1,i=o.rowCount||1;return n._scale=o.scale||1,n._panScale=.21*n._scale,n._frameCount=r*i,n._sprites=new g(t,o).on({load:function(t){n.trigger("load",t)},imageError:function(t){n.trigger("imageError",{imageUrl:t.imageUrl})}}),n._panInput=new l.PanInput(n._el,{scale:[n._panScale,n._panScale]}),n._axes=new l({angle:{range:[0,359],circular:!0}}).on({change:function(t){var e=Math.floor(t.pos.angle/(360/n._frameCount)),o=n._frameCount-e-1;n._sprites.setFrameIndex(o),n.trigger("change",{frameIndex:o,colRow:n._sprites.getColRow(),angle:t.pos.angle})},animationEnd:function(t){n.trigger("animationEnd",{isTrusted:t.isTrusted})}}),n._axes.connect("angle",n._panInput),n}o(t,a);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}(e);return t.VERSION=c,t}();t.SpinViewer=_,t.SpriteImage=g,t.VERSION=c,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=view360.spinviewer.min.js.map