diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index e96acc0e0..801955cf8 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.6 + * Photo Sphere Viewer v2.7 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine @@ -65,6 +65,8 @@ * @param {boolean} [args.smooth_user_moves=true] - If set to `false` user moves have a speed fixed by `long_offset` and `lat_offset` * @param {number} [args.long_offset=π/360] - The longitude to travel per pixel moved by mouse/touch * @param {number} [args.lat_offset=π/180] - The latitude to travel per pixel moved by mouse/touch + * @param {number|string} [args.keyboard_long_offset=π/60] - The longitude to travel when the user hits the left/right arrow + * @param {number|string} [args.keyboard_lat_offset=π/120] - The latitude to travel when the user hits the up/down arrow * @param {integer} [args.time_anim=2000] - Delay before automatically animating the panorama in milliseconds, `false` to not animate * @param {boolean} [args.reverse_anim=true] - `true` if horizontal animation must be reversed when min/max longitude is reached (only if the whole circle is not described) * @param {string} [args.anim_speed=2rpm] - Animation speed in radians/degrees/revolutions per second/minute @@ -267,6 +269,13 @@ var PhotoSphereViewer = function(args) { var getAttribute = function(data, attr) { var a = data.indexOf('GPano:' + attr) + attr.length + 8, b = data.indexOf('"', a); + + if (b == -1) { + // XML-Metadata + a = data.indexOf('GPano:' + attr) + attr.length + 7; + b = data.indexOf('<', a); + } + return data.substring(a, b); }; @@ -552,6 +561,8 @@ var PhotoSphereViewer = function(args) { addEvent(canvas_container, 'mousewheel', onMouseWheel); addEvent(canvas_container, 'DOMMouseScroll', onMouseWheel); } + + self.addAction('fullscreen-mode', toggleArrowKeys); } addEvent(document, 'fullscreenchange', fullscreenToggled); @@ -896,6 +907,76 @@ var PhotoSphereViewer = function(args) { moveTo(longitude, latitude); }; + /** + * Rotates the view + * @private + * @param {number|string} dlong - The rotation to apply horizontally + * @param {number|string} dlat - The rotation to apply vertically + * @return {void} + **/ + + var rotate = function(dlong, dlat) { + dlong = parseAngle(dlong); + dlat = parseAngle(dlat); + + moveTo(long + dlong, lat + dlat); + }; + + /** + * Rotates the view + * @public + * @param {number|string} dlong - The rotation to apply horizontally + * @param {number|string} dlat - The rotation to apply vertically + * @return {void} + **/ + + this.rotate = function(dlong, dlat) { + rotate(dlong, dlat); + }; + + /** + * Attaches or detaches the keyboard events + * @private + * @param {boolean} attach - `true` to attach the event, `false` to detach it + * @return {void} + **/ + + var toggleArrowKeys = function(attach) { + var action = (attach) ? window.addEventListener : window.removeEventListener; + action('keydown', keyDown); + }; + + /** + * Rotates the view through keyboard arrows + * @private + * @param {KeyboardEvent} evt - The event + * @return {void} + **/ + + var keyDown = function(evt) { + var dlong = 0, dlat = 0; + + switch (evt.key) { + case 'ArrowUp': + dlat = PSV_KEYBOARD_LAT_OFFSET; + break; + + case 'ArrowRight': + dlong = -PSV_KEYBOARD_LONG_OFFSET; + break; + + case 'ArrowDown': + dlat = -PSV_KEYBOARD_LAT_OFFSET; + break; + + case 'ArrowLeft': + dlong = PSV_KEYBOARD_LONG_OFFSET; + break; + } + + rotate(dlong, dlat); + }; + /** * The user wants to move. * @private @@ -1495,6 +1576,9 @@ var PhotoSphereViewer = function(args) { var PSV_LONG_OFFSET = (args.long_offset !== undefined) ? parseAngle(args.long_offset) : Math.PI / 360.0; var PSV_LAT_OFFSET = (args.lat_offset !== undefined) ? parseAngle(args.lat_offset) : Math.PI / 180.0; + var PSV_KEYBOARD_LONG_OFFSET = (args.keyboard_long_offset !== undefined) ? parseAngle(args.keyboard_long_offset) : Math.PI / 60.0; + var PSV_KEYBOARD_LAT_OFFSET = (args.keyboard_lat_offset !== undefined) ? parseAngle(args.keyboard_lat_offset) : Math.PI / 120.0; + // Minimum and maximum fields of view in degrees var PSV_FOV_MIN = (args.min_fov !== undefined) ? stayBetween(parseFloat(args.min_fov), 1, 179) : 30; var PSV_FOV_MAX = (args.max_fov !== undefined) ? stayBetween(parseFloat(args.max_fov), 1, 179) : 90; @@ -1718,6 +1802,7 @@ var PhotoSphereViewer = function(args) { } // Function to call once panorama is ready? + var self = this; if (args.onready !== undefined) this.addAction('ready', args.onready); diff --git a/photo-sphere-viewer.min.js b/photo-sphere-viewer.min.js index 02595dd32..c0e5c5888 100644 --- a/photo-sphere-viewer.min.js +++ b/photo-sphere-viewer.min.js @@ -1 +1 @@ -var PhotoSphereViewer=function(e){var t=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},o=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},i=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},n=function(e,t,o){return Math.max(t,Math.min(o,e))},r=function(e,t,o,i){var n=o-e,r=i-t;return n*n+r*r},a=function(e,t){return t=void 0!==t?!!t:!1,t&&e==2*Math.PI?2*Math.PI:e-2*Math.floor(e/(2*Math.PI))*Math.PI};this.load=function(){if(Ce.innerHTML="",Ze&&1===Ze.nodeType)Ce.appendChild(Ze);else if(Ze&&"string"==typeof Ze)Ce.innerHTML=Ze;else if(Ue){var e=document.createElement("img");e.setAttribute("src",Ue),e.setAttribute("alt",je),Ce.appendChild(e)}else Ce.textContent=je;return Ee=document.createElement("div"),Ee.style.width="100%",Ee.style.height="100%",Ee.style.position="relative",Ee.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(xe={width:0,height:0,ratio:0},void(Ne&&!Te.match(/^data:image\/[a-z]+;base64/)?d():c())):void(Ce.textContent="Canvas is not supported, update your browser!")};var s=function(e){for(var t=0,o=0,i="";-1!=(t=e.indexOf("",t));)if(i=e.substring(t,o),-1!=i.indexOf("GPano:"))return i;return""},l=function(e,t){var o=e.indexOf("GPano:"+t)+t.length+8,i=e.indexOf('"',o);return e.substring(o,i)},d=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(Ce.textContent="XHR is not supported, update your browser!");try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){e=new ActiveXObject("Microsoft.XMLHTTP")}}e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var t=s(e.responseText);if(!t.length)return void c();qe={full_width:parseInt(l(t,"FullPanoWidthPixels")),full_height:parseInt(l(t,"FullPanoHeightPixels")),cropped_width:parseInt(l(t,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(l(t,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(l(t,"CroppedAreaLeftPixels")),cropped_y:parseInt(l(t,"CroppedAreaTopPixels"))},Ye=!0,c()}},e.open("GET",Te,!0),e.send(null)},c=function(){var e=new Image;e.onload=function(){var t={full_width:e.width,full_height:e.height,cropped_width:e.width,cropped_height:e.height,cropped_x:null,cropped_y:null};if(360!=Ge.horizontal_fov||180!=Ge.vertical_fov){if(qe.cropped_width=t.cropped_width,qe.cropped_height=t.cropped_height,qe.full_width=t.full_width,qe.full_height=t.full_height,360!=Ge.horizontal_fov){var i=Ge.horizontal_fov/360;qe.full_width=qe.cropped_width/i}if(180!=Ge.vertical_fov){var n=Ge.vertical_fov/180;qe.full_height=qe.cropped_height/n}}else{for(var r in qe)null===qe[r]&&void 0!==t[r]&&(qe[r]=t[r]);if(Ye){if(qe.cropped_width!=t.cropped_width){var a=t.cropped_width/qe.cropped_width;qe.cropped_width=t.cropped_width,qe.full_width*=a,qe.cropped_x*=a}if(qe.cropped_height!=t.cropped_height){var s=t.cropped_height/qe.cropped_height;qe.cropped_height=t.cropped_height,qe.full_height*=s,qe.cropped_y*=s}}}null===qe.cropped_x&&(qe.cropped_x=(qe.full_width-qe.cropped_width)/2),null===qe.cropped_y&&(qe.cropped_y=(qe.full_height-qe.cropped_height)/2);var l=2048;if(o()){var d=document.createElement("canvas"),c=d.getContext("webgl");l=c.getParameter(c.MAX_TEXTURE_SIZE)}var h=Math.min(qe.full_width,l),p=h/qe.full_width;qe.full_width=h,qe.cropped_width*=p,qe.cropped_x*=p,e.width=qe.cropped_width,qe.full_height*=p,qe.cropped_height*=p,qe.cropped_y*=p,e.height=qe.cropped_height;var g=document.createElement("canvas");g.width=qe.full_width,g.height=qe.full_height;var v=g.getContext("2d");v.drawImage(e,qe.cropped_x,qe.cropped_y,qe.cropped_width,qe.cropped_height),u(g.toDataURL("image/jpeg"))},$e&&!Te.match(/^data:image\/[a-z]+;base64/)&&e.setAttribute("crossOrigin","anonymous"),e.src=Te},u=function(e){var t=new THREE.Texture,o=new THREE.ImageLoader,i=function(e){t.needsUpdate=!0,t.image=e,h(t)};o.load(e,i)},h=function(e){void 0!==ke.width&&(Ce.style.width=ke.width.css),void 0!==ke.height&&(Ce.style.height=ke.height.css),x(),Re=o()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,Re.setSize(xe.width,xe.height),Ie=new THREE.Scene,Me=new THREE.PerspectiveCamera(U,xe.ratio,1,300),Me.position.set(0,0,0),Ie.add(Me);var t=new THREE.SphereGeometry(200,32,32),n=new THREE.MeshBasicMaterial({map:e,overdraw:!0}),r=new THREE.Mesh(t,n);if(r.scale.x=-1,Ie.add(r),Se=document.createElement("div"),Se.style.position="absolute",Se.style.zIndex=0,Ee.appendChild(Se),fe&&(me.setStyle(ye),me.create(),Ee.appendChild(me.getBar())),null!==Ke){var a=document.createElement("img");a.onload=function(){a.style.display="block",a.style.position="absolute",a.style[Ke.position.x]="5px",a.style[Ke.position.y]="5px","bottom"==Ke.position.y&&fe&&(a.style.bottom=me.getBar().offsetHeight+5+"px"),void 0!==Ke.size&&(a.style.width=Ke.size.width,a.style.height=Ke.size.height),Ee.appendChild(a)},a.src=Ke.image}i(window,"resize",x),be&&(i(Se,"mousedown",C),i(document,"mousemove",T),i(Se,"mousemove",X),i(document,"mouseup",S),i(Se,"touchstart",k),i(document,"touchend",S),i(document,"touchmove",R),we&&(i(Se,"mousewheel",F),i(Se,"DOMMouseScroll",F))),i(document,"fullscreenchange",L),i(document,"mozfullscreenchange",L),i(document,"webkitfullscreenchange",L),i(document,"MSFullscreenChange",L),Xe.addListener(H),Ce.innerHTML="",Ce.appendChild(Ee);var s=Re.domElement;s.style.display="block",Se.appendChild(s),p(),ae>0&&B(ae),m(),q("ready")},p=function(){var e=new THREE.Vector3;e.setX(Math.cos(ie)*Math.sin(ne)),e.setY(Math.sin(ie)),e.setZ(Math.cos(ie)*Math.cos(ne)),Me.lookAt(e),null!==Pe?Pe.render(Ie,Me):Re.render(Ie,Me)},g=function(){Pe=new THREE.StereoEffect(Re),Pe.eyeSeparation=_e,Pe.setSize(xe.width,xe.height),M(),A(),me.mustBeHidden(),p(),q("stereo-effect",!0)},v=function(){Pe=null,Re.setSize(xe.width,xe.height),me.mustBeHidden(!1),p(),q("stereo-effect",!1)};this.toggleStereo=function(){null!==Pe?v():g()};var m=function(){ce!==!1&&(De=setTimeout(y,ce))},f=function(){ie-=(ie-ge)*pe,ne+=ue;var e=!0;ee||(ne=n(ne,te,oe),(ne==te||ne==oe)&&(he?ue*=-1:(b(),e=!1))),ne=a(ne,!0),q("position-updated",{longitude:ne,latitude:ie}),p(),e&&(Ae=setTimeout(f,de))},y=function(){f(),q("autorotate",!0)},b=function(){clearTimeout(De),De=null,clearTimeout(Ae),Ae=null,q("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(De),Ae?b():y()};var x=function(){(Ce.clientWidth!=xe.width||Ce.clientHeight!=xe.height)&&w({width:Ce.clientWidth,height:Ce.clientHeight})};this.fitToContainer=function(){x()};var w=function(e){xe.width=void 0!==e.width?parseInt(e.width):xe.width,xe.height=void 0!==e.height?parseInt(e.height):xe.height,xe.ratio=xe.width/xe.height,Me&&(Me.aspect=xe.ratio,Me.updateProjectionMatrix()),Re&&(Re.setSize(xe.width,xe.height),p()),Pe&&(Pe.setSize(xe.width,xe.height),p())};this.getPosition=function(){return{longitude:ne,latitude:ie}},this.getPositionInDegrees=function(){return{longitude:180*ne/Math.PI,latitude:180*ie/Math.PI}};var _=function(e,t){var o=N(e);ee||(o=n(o,te,oe));var i=N(t);i>Math.PI&&(i-=2*Math.PI),i=n(i,K,Z),ne=o,ie=i,q("position-updated",{longitude:ne,latitude:ie}),p()};this.moveTo=function(e,t){_(e,t)};var C=function(e){z(parseInt(e.clientX),parseInt(e.clientY))},k=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==Se&&z(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(S(),e.touches[0].target.parentNode==Se&&e.touches[1].target.parentNode==Se&&E(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));X()},z=function(e,t){Fe=e,Be=t,b(),He=!0},E=function(e){Le=e,Oe=!0},S=function(e){He=!1,Oe=!1},T=function(e){e.preventDefault(),I(parseInt(e.clientX),parseInt(e.clientY))},R=function(e){if(1==e.touches.length&&He){var t=e.touches[0];t.target.parentNode==Se&&(e.preventDefault(),I(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==Se&&e.touches[1].target.parentNode==Se&&Oe){e.preventDefault();var o=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),i=o-Le;if(0!==i){var n=i/Math.abs(i);B(ae+n),Le=o}}},I=function(e,t){He&&(V?(ne+=(e-Fe)/xe.height*se*Math.PI/180,ie+=(t-Be)/xe.height*se*Math.PI/180):(ne+=(e-Fe)*G,ie+=(t-Be)*Y),Fe=e,Be=t,ee||(ne=n(ne,te,oe)),ne=a(ne,!0),ie=n(ie,K,Z),q("position-updated",{longitude:ne,latitude:ie}),p())},M=function(){Xe.start(),b(),q("device-orientation",!0)},P=function(){Xe.stop(),q("device-orientation",!1)};this.toggleDeviceOrientation=function(){Xe.isEventAttached()?P():M()};var H=function(e){ne=n(e.longitude,te,oe),ie=n(e.latitude,K,Z),q("position-updated",{longitude:ne,latitude:ie}),p()},F=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!==t){var o=parseInt(t/Math.abs(t));B(ae+o)}},B=function(e){ae=n(parseInt(Math.round(e)),0,100),se=U+ae/100*(j-U),Me.fov=se,Me.updateProjectionMatrix(),p(),q("zoom-updated",ae)};this.getZoomLevel=function(){return ae},this.zoom=function(e){B(e)},this.zoomIn=function(){100>ae&&B(ae+1)},this.zoomOut=function(){ae>0&&B(ae-1)};var O=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},L=function(){document.webkitFullscreenElement||document.msFullscreenElement?(ze.width=Ce.style.width,ze.height=Ce.style.height,Ce.style.width="100%",Ce.style.height="100%",x()):(Ce.webkitRequestFullscreen||Ce.msRequestFullscreen)&&(Ce.style.width=ze.width,Ce.style.height=ze.height,x()),q("fullscreen-mode",O())},A=function(){Ce.requestFullscreen?Ce.requestFullscreen():Ce.mozRequestFullScreen?Ce.mozRequestFullScreen():Ce.webkitRequestFullscreen?Ce.webkitRequestFullscreen():Ce.msRequestFullscreen&&Ce.msRequestFullscreen()},D=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){O()?D():A()};var X=function(){fe&&me.show()},W=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();o.match(/(pm|per minute)$/)&&(t/=60);var i=0;switch(o){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":i=2*t*Math.PI;break;case"dpm":case"deg per minute":case"degrees per minute":case"dps":case"deg per second":case"degrees per second":i=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":i=t;break;default:m_anim=!1}return i*de/1e3},N=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==o&&(t*=Math.PI/180),a(t)},$=function(e){for(var t in e)if("width"==t||"height"==t){var o=e[t].toString().trim(),i=parseFloat(o.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=o.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=n&&(n="px"),ke[t]={css:i+n,unit:n}}};this.addAction=function(e,t){e in We||(We[e]=[]),We[e].push(t)};var q=function(e,t){if(e in We&&We[e].length)for(var o=0,i=We[e].length;i>o;++o)void 0!==t?We[e][o](t):We[e][o]()};if(void 0===e||void 0===e.panorama||void 0===e.container)return void console.log("PhotoSphereViewer: no value given for panorama or container");var V=void 0!==e.smooth_user_moves?!!e.smooth_user_moves:!0,G=void 0!==e.long_offset?N(e.long_offset):Math.PI/360,Y=void 0!==e.lat_offset?N(e.lat_offset):Math.PI/180,j=void 0!==e.min_fov?n(parseFloat(e.min_fov),1,179):30,U=void 0!==e.max_fov?n(parseFloat(e.max_fov),1,179):90,Z=void 0!==e.tilt_up_max?n(N(e.tilt_up_max),0,Math.PI/2):Math.PI/2,K=void 0!==e.tilt_down_max?-n(N(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,J=void 0!==e.min_longitude?N(e.min_longitude):0,Q=void 0!==e.max_longitude?N(e.max_longitude):0,ee=J==Q;ee?(J=0,Q=2*Math.PI):0===Q&&(Q=2*Math.PI);var te,oe;Q>J?(te=J,oe=Q):(te=Q,oe=J);var ie=0,ne=te;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var re=N(e.default_position.lat);re>Math.PI&&(re-=2*Math.PI),ie=n(re,K,Z)}void 0!==e.default_position["long"]&&(ne=n(N(e.default_position["long"]),te,oe))}var ae=0;void 0!==e.zoom_level&&(ae=n(parseInt(Math.round(e.zoom_level)),0,100));var se=U+ae/100*(j-U),le=60,de=1e3/le,ce=2e3;void 0!==e.time_anim&&(ce="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var ue=W(void 0!==e.anim_speed?e.anim_speed:"2rpm"),he=!0;void 0!==e.reverse_anim&&(he=!!e.reverse_anim);var pe=W(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),ge=0;if(void 0!==e.vertical_anim_target){var ve=N(e.vertical_anim_target);ve>Math.PI&&(ve-=2*Math.PI),ge=n(ve,K,Z)}var me=new PSVNavBar(this),fe=void 0!==e.navbar?!!e.navbar:!1,ye=void 0!==e.navbar_style?e.navbar_style:{},be=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;be||(fe=!1);var xe,we=void 0!==e.allow_scroll_to_zoom?!!e.allow_scroll_to_zoom:!0,_e=void 0!==e.eyes_offset?parseFloat(e.eyes_offset):5,Ce="string"==typeof e.container?document.getElementById(e.container):e.container,ke={},ze={};void 0!==e.size&&$(e.size);var Ee,Se,Te=e.panorama,Re=null,Ie=null,Me=null,Pe=null,He=!1,Fe=0,Be=0,Oe=!1,Le=0,Ae=null,De=null,Xe=new Sphoords,We={},Ne=void 0!==e.usexmpdata?!!e.usexmpdata:!0,$e=void 0!==e.cors_anonymous?!!e.cors_anonymous:!0,qe={full_width:null,full_height:null,cropped_width:null,cropped_height:null,cropped_x:null,cropped_y:null};if(void 0!==e.pano_size){for(var Ve in qe)void 0!==e.pano_size[Ve]&&(qe[Ve]=parseInt(e.pano_size[Ve]));Ne=!1}var Ge={horizontal_fov:360,vertical_fov:180};if(void 0!==e.captured_view){for(var Ve in Ge)void 0!==e.captured_view[Ve]&&(Ge[Ve]=parseFloat(e.captured_view[Ve]));Ne=!1}var Ye=!1,je=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Ue=void 0!==e.loading_img?e.loading_img.toString():null,Ze=void 0!==e.loading_html?e.loading_html:null,Ke=null;void 0!==e.overlay&&void 0!==e.overlay.image&&(Ke={image:e.overlay.image,position:{x:"left",y:"bottom"}},void 0!==e.overlay.position&&(void 0===e.overlay.position.x||"left"!=e.overlay.position.x&&"right"!=e.overlay.position.x||(Ke.position.x=e.overlay.position.x),void 0===e.overlay.position.y||"top"!=e.overlay.position.y&&"bottom"!=e.overlay.position.y||(Ke.position.y=e.overlay.position.y)),void 0!==e.overlay.size&&(Ke.size={width:void 0!==e.overlay.size.width?e.overlay.size.width:"auto",height:void 0!==e.overlay.size.height?e.overlay.size.height:"auto"})),void 0!==e.onready&&this.addAction("ready",e.onready);var Je=void 0!==e.autoload?!!e.autoload:!0;Je&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var o=0,i=t.length;i>o;++o)if(t[o]==e)return!0;return!1},o=function(e,o){return t(e,h)&&"string"==typeof o&&("transparent"==o||!!o.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!o.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/)||!!o.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/))||t(e,p)&&!isNaN(parseFloat(o))&&isFinite(o)&&o>=0};this.setStyle=function(e){for(var t in e)t in u&&o(t,e[t])&&(u[t]=e[t])},this.create=function(){r=document.createElement("div"),r.style.backgroundColor=u.backgroundColor,r.style.position="absolute",r.style.zIndex=10,r.style.bottom=0,r.style.width="100%",r.style.boxSizing="content-box",r.style.transition="bottom 0.4s ease-out",a=new PSVNavBarButton(e,"autorotate",u),r.appendChild(a.getButton()),s=new PSVNavBarButton(e,"zoom",u),r.appendChild(s.getButton()),l=new PSVNavBarButton(e,"fullscreen",u),r.appendChild(l.getButton()),Sphoords.isDeviceOrientationSupported&&(d=new PSVNavBarButton(e,"orientation",u),r.appendChild(d.getButton()),c=new PSVNavBarButton(e,"virtual-reality",u),r.appendChild(c.getButton()))},this.getBar=function(){return r};var i=function(){g&&(clearTimeout(g),!v&&m&&(g=setTimeout(n,5e3))),v&&(r.style.bottom=0,v=!1,m&&(g=setTimeout(n,5e3)))};this.show=function(){i()};var n=function(){v||(r.style.bottom=-r.offsetHeight+1+"px",v=!0)};this.hide=function(){n()},this.isHidden=function(){return v},this.mustBeHidden=function(e){m=void 0!==e?!!e:!0,m?n():i()};var r,a,s,l,d,c,u={backgroundColor:"rgba(61, 61, 61, 0.5)",buttonsColor:"rgba(255, 255, 255, 0.7)",buttonsBackgroundColor:"transparent",activeButtonsBackgroundColor:"rgba(255, 255, 255, 0.1)",buttonsHeight:20,autorotateThickness:1,zoomRangeWidth:50,zoomRangeThickness:1,zoomRangeDisk:7,fullscreenRatio:4/3,fullscreenThickness:2,gyroscopeThickness:1,virtualRealityRatio:4/3,virtualRealityBorderRadius:2},h=["backgroundColor","buttonsColor","buttonsBackgroundColor","activeButtonsBackgroundColor"],p=["buttonsHeight","autorotateThickness","zoomRangeWidth","zoomRangeThickness","zoomRangeDisk","fullscreenRatio","fullscreenThickness"],g=null,v=!1,m=!1},PSVNavBarButton=function(e,t,o){var i=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},n=function(){switch(t){case"autorotate":var n=o.buttonsHeight-2*o.autorotateThickness,p=n/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",i(l,"click",function(){e.toggleAutorotate()});var f=document.createElement("div");f.style.boxSizing="inherit",f.style.width=n+"px",f.style.height=n+"px",f.style.borderRadius="50%",f.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,l.appendChild(f);var y=document.createElement("div");y.style.boxSizing="inherit",y.style.width=n+"px",y.style.height=p+"px",y.style.borderRadius="50%",y.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,y.style.position="absolute",y.style.top="50%",y.style.marginTop=-(p/2+o.autorotateThickness)+"px",l.appendChild(y),e.addAction("autorotate",d);break;case"zoom":l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit";var b=document.createElement("div");b.style.cssFloat="left",b.style.boxSizing="inherit",b.style.padding="10px",b.style.height=o.buttonsHeight+"px",b.style.backgroundColor=o.buttonsBackgroundColor,b.style.lineHeight=o.buttonsHeight+"px",b.style.color=o.buttonsColor,b.style.cursor="pointer",b.textContent="-",i(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.boxSizing="inherit",r.style.padding=10+(o.buttonsHeight-o.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=o.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.boxSizing="inherit",a.style.width=o.zoomRangeWidth+"px",a.style.height=o.zoomRangeThickness+"px",a.style.backgroundColor=o.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(o.zoomRangeThickness-o.zoomRangeDisk)/2+"px",s.style.left=-(o.zoomRangeDisk/2)+"px",s.style.boxSizing="inherit",s.style.width=o.zoomRangeDisk+"px",s.style.height=o.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=o.buttonsColor,e.addAction("zoom-updated",c),i(r,"mousedown",u),i(r,"touchstart",h),i(document,"mousemove",v),i(document,"touchmove",m),i(document,"mouseup",g),i(document,"touchend",g),a.appendChild(s);var x=document.createElement("div");x.style.cssFloat="left",x.style.boxSizing="inherit",x.style.padding="10px",x.style.height=o.buttonsHeight+"px",x.style.backgroundColor=o.buttonsBackgroundColor,x.style.lineHeight=o.buttonsHeight+"px",x.style.color=o.buttonsColor,x.style.cursor="pointer",x.textContent="+",i(x,"click",function(){e.zoomIn()}),l.appendChild(x);break;case"fullscreen":var w=o.buttonsHeight*o.fullscreenRatio,_=.3*o.buttonsHeight,C=(o.buttonsHeight-_)/2,k=.3*w,z=(w-k)/2-o.fullscreenThickness,E=o.buttonsHeight-2*o.fullscreenThickness;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=w+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",i(l,"click",function(){e.toggleFullscreen()});var S=document.createElement("div");S.style.cssFloat="left",S.style.boxSizing="inherit",S.style.width=o.fullscreenThickness+"px",S.style.height=_+"px",S.style.borderStyle="solid",S.style.borderColor=o.buttonsColor+" transparent",S.style.borderWidth=C+"px 0",l.appendChild(S);var T=document.createElement("div");T.style.cssFloat="left",T.style.boxSizing="inherit",T.style.width=z+"px",T.style.height=E+"px",T.style.borderStyle="solid",T.style.borderColor=o.buttonsColor+" transparent",T.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(T);var R=document.createElement("div");R.style.cssFloat="left",R.style.boxSizing="inherit",R.style.marginLeft=k+"px",R.style.width=z+"px",R.style.height=E+"px",R.style.borderStyle="solid",R.style.borderColor=o.buttonsColor+" transparent",R.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(R);var I=document.createElement("div");I.style.cssFloat="left",I.style.boxSizing="inherit",I.style.width=o.fullscreenThickness+"px",I.style.height=_+"px",I.style.borderStyle="solid",I.style.borderColor=o.buttonsColor+" transparent",I.style.borderWidth=C+"px 0",l.appendChild(I);var M=document.createElement("div");M.style.clear="left",l.appendChild(M),e.addAction("fullscreen-mode",d);break;case"orientation":var P=o.buttonsHeight-2*o.gyroscopeThickness,H=P-4*o.gyroscopeThickness,F=P/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",i(l,"click",function(){e.toggleDeviceOrientation()});var B=document.createElement("div");B.style.boxSizing="inherit",B.style.width=P+"px",B.style.height=P+"px",B.style.borderRadius="50%",B.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,l.appendChild(B);var O=document.createElement("div");O.style.boxSizing="inherit",O.style.width=H+"px",O.style.height=F+"px",O.style.borderRadius="50%",O.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,O.style.position="absolute",O.style.top="50%",O.style.left="50%",O.style.marginTop=-(F/2+o.gyroscopeThickness)+"px",O.style.marginLeft=-(H/2+o.gyroscopeThickness)+"px",l.appendChild(O);var L=document.createElement("div");L.style.boxSizing="inherit",L.style.width=F+"px",L.style.height=H+"px",L.style.borderRadius="50%",L.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,L.style.position="absolute",L.style.top="50%",L.style.left="50%",L.style.marginTop=-(H/2+o.gyroscopeThickness)+"px",L.style.marginLeft=-(F/2+o.gyroscopeThickness)+"px",l.appendChild(L),e.addAction("device-orientation",d);break;case"virtual-reality":var A=o.buttonsHeight*o.virtualRealityRatio,D=A/4,X=D/2;l=document.createElement("div"),l.style.cssFloat="right",l.style.position="relative",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=A+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",i(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.boxSizing="inherit",W.style.width=A+"px",W.style.height=o.buttonsHeight+"px",W.style.borderRadius=o.virtualRealityBorderRadius+"px",W.style.backgroundColor=o.buttonsColor,l.appendChild(W);var N=document.createElement("div");N.style.boxSizing="inherit",N.style.width=D+"px",N.style.height=D+"px",N.style.position="absolute",N.style.top=X+10+"px",N.style.left=X+10+"px",N.style.borderRadius="50%",N.style.backgroundColor=o.backgroundColor,l.appendChild(N);var $=document.createElement("div");$.style.boxSizing="inherit",$.style.width=D+"px",$.style.height=D+"px",$.style.position="absolute",$.style.top=X+10+"px",$.style.right=X+10+"px",$.style.borderRadius="50%",$.style.backgroundColor=o.backgroundColor,l.appendChild($);var q=document.createElement("div");q.style.boxSizing="inherit",q.style.width=D+"px",q.style.height=o.buttonsHeight/2+"px",q.style.position="absolute",q.style.left="50%",q.style.bottom="10px",q.style.marginLeft=-(D/2)+"px",q.style.borderTopLeftRadius="50% 60%",q.style.borderTopRightRadius="50% 60%",q.style.backgroundColor=o.backgroundColor,l.appendChild(q),e.addAction("stereo-effect",d)}};this.getButton=function(){return l};var r,a,s,l,d=function(e){e?l.style.backgroundColor=o.activeButtonsBackgroundColor:l.style.backgroundColor=o.buttonsBackgroundColor},c=function(e){s.style.left=e/100*o.zoomRangeWidth-o.zoomRangeDisk/2+"px"},u=function(e){p(parseInt(e.clientX))},h=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&p(parseInt(t.clientX))},p=function(e){y=!0,f(e)},g=function(e){y=!1},v=function(e){e.preventDefault(),f(parseInt(e.clientX))},m=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),f(parseInt(t.clientX)))},f=function(t){if(y){var i=t-a.getBoundingClientRect().left,n=i/o.zoomRangeWidth*100;e.zoom(n)}},y=!1;n()},Sphoords=function(){var e=function(){var e=navigator.userAgent;return/Gecko\/[0-9.]+/.test(e)?"Gecko":/Chrome\/[0-9.]+/.test(e)?"Blink":/AppleWebKit\/[0-9.]+/.test(e)?"WebKit":/Trident\/[0-9.]+/.test(e)?"Trident":/Opera\/[0-9.]+/.test(e)?"Presto":"Gecko"},t=function(e){return e-360*Math.floor(e/360)};this.start=function(){return Sphoords.isDeviceOrientationSupported?(window.addEventListener("deviceorientation",o,!1),n=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){n&&(window.removeEventListener("deviceorientation",o,!1),n=!1)},this.toggle=function(){n?this.stop():this.start()},this.isEventAttached=function(){return n};var o=function(e){c=Sphoords.getScreenOrientation();var o=0,n=0;switch(c){case"portrait-primary":o=e.alpha+e.gamma,n=e.beta-90;break;case"landscape-primary":if(o=e.alpha+e.beta-90,n=-e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":n+=180;break;case"Gecko":default:n=-n}break;case"landscape-secondary":if(o=e.alpha-e.beta+90,n=e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":n+=180;break;case"Gecko":default:n=-n}break;case"portrait-secondary":o=e.alpha-e.gamma,n=180-(e.beta-90),n=270-e.beta}n=t(n),n>=180&&(n-=360),r=t(o),a=Math.max(-90,Math.min(90,n)),s=r*d,l=a*d,i()};this.getCoordinates=function(){return{longitude:s,latitude:l}},this.getCoordinatesInDegrees=function(){return{longitude:r,latitude:a}},this.getScreenOrientation=function(){return c},this.addListener=function(e){h.push(e)};var i=function(){if(h.length)for(var e=0,t=h.length;t>e;++e)h[e]({longitude:s,latitude:l})},n=!1,r=0,a=0,s=0,l=0,d=Math.PI/180,c=Sphoords.getScreenOrientation(),u=e(),h=[]};Sphoords.getScreenOrientation=function(){var e=null;return screen.orientation?e=screen.orientation:screen.mozOrientation?e=screen.mozOrientation:screen.msOrientation&&(e=screen.msOrientation),null!==e&&"object"==typeof e?e.type:e},Sphoords.isDeviceOrientationSupported=!1,function(){function e(t){null!==t&&null!==t.alpha&&(Sphoords.isDeviceOrientationSupported=!0,window.removeEventListener("deviceorientation",e))}window.DeviceOrientationEvent&&null!==Sphoords.getScreenOrientation()&&window.addEventListener("deviceorientation",e)}(); \ No newline at end of file +var PhotoSphereViewer=function(e){var t=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},o=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},i=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},n=function(e,t,o){return Math.max(t,Math.min(o,e))},r=function(e,t,o,i){var n=o-e,r=i-t;return n*n+r*r},a=function(e,t){return t=void 0!==t?!!t:!1,t&&e==2*Math.PI?2*Math.PI:e-2*Math.floor(e/(2*Math.PI))*Math.PI};this.load=function(){if(Te.innerHTML="",tt&&1===tt.nodeType)Te.appendChild(tt);else if(tt&&"string"==typeof tt)Te.innerHTML=tt;else if(et){var e=document.createElement("img");e.setAttribute("src",et),e.setAttribute("alt",Qe),Te.appendChild(e)}else Te.textContent=Qe;return Me=document.createElement("div"),Me.style.width="100%",Me.style.height="100%",Me.style.position="relative",Me.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(ze={width:0,height:0,ratio:0},void(Ye&&!He.match(/^data:image\/[a-z]+;base64/)?d():c())):void(Te.textContent="Canvas is not supported, update your browser!")};var s=function(e){for(var t=0,o=0,i="";-1!=(t=e.indexOf("",t));)if(i=e.substring(t,o),-1!=i.indexOf("GPano:"))return i;return""},l=function(e,t){var o=e.indexOf("GPano:"+t)+t.length+8,i=e.indexOf('"',o);return-1==i&&(o=e.indexOf("GPano:"+t)+t.length+7,i=e.indexOf("<",o)),e.substring(o,i)},d=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(Te.textContent="XHR is not supported, update your browser!");try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){e=new ActiveXObject("Microsoft.XMLHTTP")}}e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var t=s(e.responseText);if(!t.length)return void c();Ue={full_width:parseInt(l(t,"FullPanoWidthPixels")),full_height:parseInt(l(t,"FullPanoHeightPixels")),cropped_width:parseInt(l(t,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(l(t,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(l(t,"CroppedAreaLeftPixels")),cropped_y:parseInt(l(t,"CroppedAreaTopPixels"))},Je=!0,c()}},e.open("GET",He,!0),e.send(null)},c=function(){var e=new Image;e.onload=function(){var t={full_width:e.width,full_height:e.height,cropped_width:e.width,cropped_height:e.height,cropped_x:null,cropped_y:null};if(360!=Ke.horizontal_fov||180!=Ke.vertical_fov){if(Ue.cropped_width=t.cropped_width,Ue.cropped_height=t.cropped_height,Ue.full_width=t.full_width,Ue.full_height=t.full_height,360!=Ke.horizontal_fov){var i=Ke.horizontal_fov/360;Ue.full_width=Ue.cropped_width/i}if(180!=Ke.vertical_fov){var n=Ke.vertical_fov/180;Ue.full_height=Ue.cropped_height/n}}else{for(var r in Ue)null===Ue[r]&&void 0!==t[r]&&(Ue[r]=t[r]);if(Je){if(Ue.cropped_width!=t.cropped_width){var a=t.cropped_width/Ue.cropped_width;Ue.cropped_width=t.cropped_width,Ue.full_width*=a,Ue.cropped_x*=a}if(Ue.cropped_height!=t.cropped_height){var s=t.cropped_height/Ue.cropped_height;Ue.cropped_height=t.cropped_height,Ue.full_height*=s,Ue.cropped_y*=s}}}null===Ue.cropped_x&&(Ue.cropped_x=(Ue.full_width-Ue.cropped_width)/2),null===Ue.cropped_y&&(Ue.cropped_y=(Ue.full_height-Ue.cropped_height)/2);var l=2048;if(o()){var d=document.createElement("canvas"),c=d.getContext("webgl");l=c.getParameter(c.MAX_TEXTURE_SIZE)}var h=Math.min(Ue.full_width,l),p=h/Ue.full_width;Ue.full_width=h,Ue.cropped_width*=p,Ue.cropped_x*=p,e.width=Ue.cropped_width,Ue.full_height*=p,Ue.cropped_height*=p,Ue.cropped_y*=p,e.height=Ue.cropped_height;var g=document.createElement("canvas");g.width=Ue.full_width,g.height=Ue.full_height;var v=g.getContext("2d");v.drawImage(e,Ue.cropped_x,Ue.cropped_y,Ue.cropped_width,Ue.cropped_height),u(g.toDataURL("image/jpeg"))},je&&!He.match(/^data:image\/[a-z]+;base64/)&&e.setAttribute("crossOrigin","anonymous"),e.src=He},u=function(e){var t=new THREE.Texture,o=new THREE.ImageLoader,i=function(e){t.needsUpdate=!0,t.image=e,h(t)};o.load(e,i)},h=function(e){void 0!==Re.width&&(Te.style.width=Re.width.css),void 0!==Re.height&&(Te.style.height=Re.height.css),x(),Fe=o()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,Fe.setSize(ze.width,ze.height),Be=new THREE.Scene,Ae=new THREE.PerspectiveCamera(ee,ze.ratio,1,300),Ae.position.set(0,0,0),Be.add(Ae);var t=new THREE.SphereGeometry(200,32,32),n=new THREE.MeshBasicMaterial({map:e,overdraw:!0}),r=new THREE.Mesh(t,n);if(r.scale.x=-1,Be.add(r),Pe=document.createElement("div"),Pe.style.position="absolute",Pe.style.zIndex=0,Me.appendChild(Pe),_e&&(we.setStyle(ke),we.create(),Me.appendChild(we.getBar())),null!==ot){var a=document.createElement("img");a.onload=function(){a.style.display="block",a.style.position="absolute",a.style[ot.position.x]="5px",a.style[ot.position.y]="5px","bottom"==ot.position.y&&_e&&(a.style.bottom=we.getBar().offsetHeight+5+"px"),void 0!==ot.size&&(a.style.width=ot.size.width,a.style.height=ot.size.height),Me.appendChild(a)},a.src=ot.image}i(window,"resize",x),Ce&&(i(Pe,"mousedown",E),i(document,"mousemove",M),i(Pe,"mousemove",$),i(document,"mouseup",I),i(Pe,"touchstart",S),i(document,"touchend",I),i(document,"touchmove",P),Ee&&(i(Pe,"mousewheel",L),i(Pe,"DOMMouseScroll",L)),it.addAction("fullscreen-mode",C)),i(document,"fullscreenchange",X),i(document,"mozfullscreenchange",X),i(document,"webkitfullscreenchange",X),i(document,"MSFullscreenChange",X),Ge.addListener(A),Te.innerHTML="",Te.appendChild(Me);var s=Fe.domElement;s.style.display="block",Pe.appendChild(s),p(),ue>0&&O(ue),m(),Y("ready")},p=function(){var e=new THREE.Vector3;e.setX(Math.cos(le)*Math.sin(de)),e.setY(Math.sin(le)),e.setZ(Math.cos(le)*Math.cos(de)),Ae.lookAt(e),null!==Le?Le.render(Be,Ae):Fe.render(Be,Ae)},g=function(){Le=new THREE.StereoEffect(Fe),Le.eyeSeparation=Se,Le.setSize(ze.width,ze.height),F(),W(),we.mustBeHidden(),p(),Y("stereo-effect",!0)},v=function(){Le=null,Fe.setSize(ze.width,ze.height),we.mustBeHidden(!1),p(),Y("stereo-effect",!1)};this.toggleStereo=function(){null!==Le?v():g()};var m=function(){ve!==!1&&(qe=setTimeout(y,ve))},f=function(){le-=(le-be)*ye,de+=me;var e=!0;re||(de=n(de,ae,se),(de==ae||de==se)&&(fe?me*=-1:(b(),e=!1))),de=a(de,!0),Y("position-updated",{longitude:de,latitude:le}),p(),e&&($e=setTimeout(f,ge))},y=function(){f(),Y("autorotate",!0)},b=function(){clearTimeout(qe),qe=null,clearTimeout($e),$e=null,Y("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(qe),$e?b():y()};var x=function(){(Te.clientWidth!=ze.width||Te.clientHeight!=ze.height)&&w({width:Te.clientWidth,height:Te.clientHeight})};this.fitToContainer=function(){x()};var w=function(e){ze.width=void 0!==e.width?parseInt(e.width):ze.width,ze.height=void 0!==e.height?parseInt(e.height):ze.height,ze.ratio=ze.width/ze.height,Ae&&(Ae.aspect=ze.ratio,Ae.updateProjectionMatrix()),Fe&&(Fe.setSize(ze.width,ze.height),p()),Le&&(Le.setSize(ze.width,ze.height),p())};this.getPosition=function(){return{longitude:de,latitude:le}},this.getPositionInDegrees=function(){return{longitude:180*de/Math.PI,latitude:180*le/Math.PI}};var _=function(e,t){var o=G(e);re||(o=n(o,ae,se));var i=G(t);i>Math.PI&&(i-=2*Math.PI),i=n(i,oe,te),de=o,le=i,Y("position-updated",{longitude:de,latitude:le}),p()};this.moveTo=function(e,t){_(e,t)};var k=function(e,t){e=G(e),t=G(t),_(de+e,le+t)};this.rotate=function(e,t){k(e,t)};var C=function(e){var t=e?window.addEventListener:window.removeEventListener;t("keydown",z)},z=function(e){var t=0,o=0;switch(e.key){case"ArrowUp":o=J;break;case"ArrowRight":t=-K;break;case"ArrowDown":o=-J;break;case"ArrowLeft":t=K}k(t,o)},E=function(e){T(parseInt(e.clientX),parseInt(e.clientY))},S=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==Pe&&T(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(I(),e.touches[0].target.parentNode==Pe&&e.touches[1].target.parentNode==Pe&&R(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));$()},T=function(e,t){De=e,Xe=t,b(),Oe=!0},R=function(e){Ne=e,We=!0},I=function(e){Oe=!1,We=!1},M=function(e){e.preventDefault(),H(parseInt(e.clientX),parseInt(e.clientY))},P=function(e){if(1==e.touches.length&&Oe){var t=e.touches[0];t.target.parentNode==Pe&&(e.preventDefault(),H(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==Pe&&e.touches[1].target.parentNode==Pe&&We){e.preventDefault();var o=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),i=o-Ne;if(0!==i){var n=i/Math.abs(i);O(ue+n),Ne=o}}},H=function(e,t){Oe&&(j?(de+=(e-De)/ze.height*he*Math.PI/180,le+=(t-Xe)/ze.height*he*Math.PI/180):(de+=(e-De)*U,le+=(t-Xe)*Z),De=e,Xe=t,re||(de=n(de,ae,se)),de=a(de,!0),le=n(le,oe,te),Y("position-updated",{longitude:de,latitude:le}),p())},F=function(){Ge.start(),b(),Y("device-orientation",!0)},B=function(){Ge.stop(),Y("device-orientation",!1)};this.toggleDeviceOrientation=function(){Ge.isEventAttached()?B():F()};var A=function(e){de=n(e.longitude,ae,se),le=n(e.latitude,oe,te),Y("position-updated",{longitude:de,latitude:le}),p()},L=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!==t){var o=parseInt(t/Math.abs(t));O(ue+o)}},O=function(e){ue=n(parseInt(Math.round(e)),0,100),he=ee+ue/100*(Q-ee),Ae.fov=he,Ae.updateProjectionMatrix(),p(),Y("zoom-updated",ue)};this.getZoomLevel=function(){return ue},this.zoom=function(e){O(e)},this.zoomIn=function(){100>ue&&O(ue+1)},this.zoomOut=function(){ue>0&&O(ue-1)};var D=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},X=function(){document.webkitFullscreenElement||document.msFullscreenElement?(Ie.width=Te.style.width,Ie.height=Te.style.height,Te.style.width="100%",Te.style.height="100%",x()):(Te.webkitRequestFullscreen||Te.msRequestFullscreen)&&(Te.style.width=Ie.width,Te.style.height=Ie.height,x()),Y("fullscreen-mode",D())},W=function(){Te.requestFullscreen?Te.requestFullscreen():Te.mozRequestFullScreen?Te.mozRequestFullScreen():Te.webkitRequestFullscreen?Te.webkitRequestFullscreen():Te.msRequestFullscreen&&Te.msRequestFullscreen()},N=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){D()?N():W()};var $=function(){_e&&we.show()},q=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();o.match(/(pm|per minute)$/)&&(t/=60);var i=0;switch(o){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":i=2*t*Math.PI;break;case"dpm":case"deg per minute":case"degrees per minute":case"dps":case"deg per second":case"degrees per second":i=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":i=t;break;default:m_anim=!1}return i*ge/1e3},G=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==o&&(t*=Math.PI/180),a(t)},V=function(e){for(var t in e)if("width"==t||"height"==t){var o=e[t].toString().trim(),i=parseFloat(o.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=o.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=n&&(n="px"),Re[t]={css:i+n,unit:n}}};this.addAction=function(e,t){e in Ve||(Ve[e]=[]),Ve[e].push(t)};var Y=function(e,t){if(e in Ve&&Ve[e].length)for(var o=0,i=Ve[e].length;i>o;++o)void 0!==t?Ve[e][o](t):Ve[e][o]()};if(void 0===e||void 0===e.panorama||void 0===e.container)return void console.log("PhotoSphereViewer: no value given for panorama or container");var j=void 0!==e.smooth_user_moves?!!e.smooth_user_moves:!0,U=void 0!==e.long_offset?G(e.long_offset):Math.PI/360,Z=void 0!==e.lat_offset?G(e.lat_offset):Math.PI/180,K=void 0!==e.keyboard_long_offset?G(e.keyboard_long_offset):Math.PI/60,J=void 0!==e.keyboard_lat_offset?G(e.keyboard_lat_offset):Math.PI/120,Q=void 0!==e.min_fov?n(parseFloat(e.min_fov),1,179):30,ee=void 0!==e.max_fov?n(parseFloat(e.max_fov),1,179):90,te=void 0!==e.tilt_up_max?n(G(e.tilt_up_max),0,Math.PI/2):Math.PI/2,oe=void 0!==e.tilt_down_max?-n(G(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,ie=void 0!==e.min_longitude?G(e.min_longitude):0,ne=void 0!==e.max_longitude?G(e.max_longitude):0,re=ie==ne;re?(ie=0,ne=2*Math.PI):0===ne&&(ne=2*Math.PI);var ae,se;ne>ie?(ae=ie,se=ne):(ae=ne,se=ie);var le=0,de=ae;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var ce=G(e.default_position.lat);ce>Math.PI&&(ce-=2*Math.PI),le=n(ce,oe,te)}void 0!==e.default_position["long"]&&(de=n(G(e.default_position["long"]),ae,se))}var ue=0;void 0!==e.zoom_level&&(ue=n(parseInt(Math.round(e.zoom_level)),0,100));var he=ee+ue/100*(Q-ee),pe=60,ge=1e3/pe,ve=2e3;void 0!==e.time_anim&&(ve="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var me=q(void 0!==e.anim_speed?e.anim_speed:"2rpm"),fe=!0;void 0!==e.reverse_anim&&(fe=!!e.reverse_anim);var ye=q(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),be=0;if(void 0!==e.vertical_anim_target){var xe=G(e.vertical_anim_target);xe>Math.PI&&(xe-=2*Math.PI),be=n(xe,oe,te)}var we=new PSVNavBar(this),_e=void 0!==e.navbar?!!e.navbar:!1,ke=void 0!==e.navbar_style?e.navbar_style:{},Ce=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;Ce||(_e=!1);var ze,Ee=void 0!==e.allow_scroll_to_zoom?!!e.allow_scroll_to_zoom:!0,Se=void 0!==e.eyes_offset?parseFloat(e.eyes_offset):5,Te="string"==typeof e.container?document.getElementById(e.container):e.container,Re={},Ie={};void 0!==e.size&&V(e.size);var Me,Pe,He=e.panorama,Fe=null,Be=null,Ae=null,Le=null,Oe=!1,De=0,Xe=0,We=!1,Ne=0,$e=null,qe=null,Ge=new Sphoords,Ve={},Ye=void 0!==e.usexmpdata?!!e.usexmpdata:!0,je=void 0!==e.cors_anonymous?!!e.cors_anonymous:!0,Ue={full_width:null,full_height:null,cropped_width:null,cropped_height:null,cropped_x:null,cropped_y:null};if(void 0!==e.pano_size){for(var Ze in Ue)void 0!==e.pano_size[Ze]&&(Ue[Ze]=parseInt(e.pano_size[Ze]));Ye=!1}var Ke={horizontal_fov:360,vertical_fov:180};if(void 0!==e.captured_view){for(var Ze in Ke)void 0!==e.captured_view[Ze]&&(Ke[Ze]=parseFloat(e.captured_view[Ze]));Ye=!1}var Je=!1,Qe=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",et=void 0!==e.loading_img?e.loading_img.toString():null,tt=void 0!==e.loading_html?e.loading_html:null,ot=null;void 0!==e.overlay&&void 0!==e.overlay.image&&(ot={image:e.overlay.image,position:{x:"left",y:"bottom"}},void 0!==e.overlay.position&&(void 0===e.overlay.position.x||"left"!=e.overlay.position.x&&"right"!=e.overlay.position.x||(ot.position.x=e.overlay.position.x),void 0===e.overlay.position.y||"top"!=e.overlay.position.y&&"bottom"!=e.overlay.position.y||(ot.position.y=e.overlay.position.y)),void 0!==e.overlay.size&&(ot.size={width:void 0!==e.overlay.size.width?e.overlay.size.width:"auto",height:void 0!==e.overlay.size.height?e.overlay.size.height:"auto"}));var it=this;void 0!==e.onready&&this.addAction("ready",e.onready);var nt=void 0!==e.autoload?!!e.autoload:!0;nt&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var o=0,i=t.length;i>o;++o)if(t[o]==e)return!0;return!1},o=function(e,o){return t(e,h)&&"string"==typeof o&&("transparent"==o||!!o.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!o.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/)||!!o.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/))||t(e,p)&&!isNaN(parseFloat(o))&&isFinite(o)&&o>=0};this.setStyle=function(e){for(var t in e)t in u&&o(t,e[t])&&(u[t]=e[t])},this.create=function(){r=document.createElement("div"),r.style.backgroundColor=u.backgroundColor,r.style.position="absolute",r.style.zIndex=10,r.style.bottom=0,r.style.width="100%",r.style.boxSizing="content-box",r.style.transition="bottom 0.4s ease-out",a=new PSVNavBarButton(e,"autorotate",u),r.appendChild(a.getButton()),s=new PSVNavBarButton(e,"zoom",u),r.appendChild(s.getButton()),l=new PSVNavBarButton(e,"fullscreen",u),r.appendChild(l.getButton()),Sphoords.isDeviceOrientationSupported&&(d=new PSVNavBarButton(e,"orientation",u),r.appendChild(d.getButton()),c=new PSVNavBarButton(e,"virtual-reality",u),r.appendChild(c.getButton()))},this.getBar=function(){return r};var i=function(){g&&(clearTimeout(g),!v&&m&&(g=setTimeout(n,5e3))),v&&(r.style.bottom=0,v=!1,m&&(g=setTimeout(n,5e3)))};this.show=function(){i()};var n=function(){v||(r.style.bottom=-r.offsetHeight+1+"px",v=!0)};this.hide=function(){n()},this.isHidden=function(){return v},this.mustBeHidden=function(e){m=void 0!==e?!!e:!0,m?n():i()};var r,a,s,l,d,c,u={backgroundColor:"rgba(61, 61, 61, 0.5)",buttonsColor:"rgba(255, 255, 255, 0.7)",buttonsBackgroundColor:"transparent",activeButtonsBackgroundColor:"rgba(255, 255, 255, 0.1)",buttonsHeight:20,autorotateThickness:1,zoomRangeWidth:50,zoomRangeThickness:1,zoomRangeDisk:7,fullscreenRatio:4/3,fullscreenThickness:2,gyroscopeThickness:1,virtualRealityRatio:4/3,virtualRealityBorderRadius:2},h=["backgroundColor","buttonsColor","buttonsBackgroundColor","activeButtonsBackgroundColor"],p=["buttonsHeight","autorotateThickness","zoomRangeWidth","zoomRangeThickness","zoomRangeDisk","fullscreenRatio","fullscreenThickness"],g=null,v=!1,m=!1},PSVNavBarButton=function(e,t,o){var i=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},n=function(){switch(t){case"autorotate":var n=o.buttonsHeight-2*o.autorotateThickness,p=n/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",i(l,"click",function(){e.toggleAutorotate()});var f=document.createElement("div");f.style.boxSizing="inherit",f.style.width=n+"px",f.style.height=n+"px",f.style.borderRadius="50%",f.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,l.appendChild(f);var y=document.createElement("div");y.style.boxSizing="inherit",y.style.width=n+"px",y.style.height=p+"px",y.style.borderRadius="50%",y.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,y.style.position="absolute",y.style.top="50%",y.style.marginTop=-(p/2+o.autorotateThickness)+"px",l.appendChild(y),e.addAction("autorotate",d);break;case"zoom":l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit";var b=document.createElement("div");b.style.cssFloat="left",b.style.boxSizing="inherit",b.style.padding="10px",b.style.height=o.buttonsHeight+"px",b.style.backgroundColor=o.buttonsBackgroundColor,b.style.lineHeight=o.buttonsHeight+"px",b.style.color=o.buttonsColor,b.style.cursor="pointer",b.textContent="-",i(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.boxSizing="inherit",r.style.padding=10+(o.buttonsHeight-o.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=o.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.boxSizing="inherit",a.style.width=o.zoomRangeWidth+"px",a.style.height=o.zoomRangeThickness+"px",a.style.backgroundColor=o.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(o.zoomRangeThickness-o.zoomRangeDisk)/2+"px",s.style.left=-(o.zoomRangeDisk/2)+"px",s.style.boxSizing="inherit",s.style.width=o.zoomRangeDisk+"px",s.style.height=o.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=o.buttonsColor,e.addAction("zoom-updated",c),i(r,"mousedown",u),i(r,"touchstart",h),i(document,"mousemove",v),i(document,"touchmove",m),i(document,"mouseup",g),i(document,"touchend",g),a.appendChild(s);var x=document.createElement("div");x.style.cssFloat="left",x.style.boxSizing="inherit",x.style.padding="10px",x.style.height=o.buttonsHeight+"px",x.style.backgroundColor=o.buttonsBackgroundColor,x.style.lineHeight=o.buttonsHeight+"px",x.style.color=o.buttonsColor,x.style.cursor="pointer",x.textContent="+",i(x,"click",function(){e.zoomIn()}),l.appendChild(x);break;case"fullscreen":var w=o.buttonsHeight*o.fullscreenRatio,_=.3*o.buttonsHeight,k=(o.buttonsHeight-_)/2,C=.3*w,z=(w-C)/2-o.fullscreenThickness,E=o.buttonsHeight-2*o.fullscreenThickness;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=w+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",i(l,"click",function(){e.toggleFullscreen()});var S=document.createElement("div");S.style.cssFloat="left",S.style.boxSizing="inherit",S.style.width=o.fullscreenThickness+"px",S.style.height=_+"px",S.style.borderStyle="solid",S.style.borderColor=o.buttonsColor+" transparent",S.style.borderWidth=k+"px 0",l.appendChild(S);var T=document.createElement("div");T.style.cssFloat="left",T.style.boxSizing="inherit",T.style.width=z+"px",T.style.height=E+"px",T.style.borderStyle="solid",T.style.borderColor=o.buttonsColor+" transparent",T.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(T);var R=document.createElement("div");R.style.cssFloat="left",R.style.boxSizing="inherit",R.style.marginLeft=C+"px",R.style.width=z+"px",R.style.height=E+"px",R.style.borderStyle="solid",R.style.borderColor=o.buttonsColor+" transparent",R.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(R);var I=document.createElement("div");I.style.cssFloat="left",I.style.boxSizing="inherit",I.style.width=o.fullscreenThickness+"px",I.style.height=_+"px",I.style.borderStyle="solid",I.style.borderColor=o.buttonsColor+" transparent",I.style.borderWidth=k+"px 0",l.appendChild(I);var M=document.createElement("div");M.style.clear="left",l.appendChild(M),e.addAction("fullscreen-mode",d);break;case"orientation":var P=o.buttonsHeight-2*o.gyroscopeThickness,H=P-4*o.gyroscopeThickness,F=P/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",i(l,"click",function(){e.toggleDeviceOrientation()});var B=document.createElement("div");B.style.boxSizing="inherit",B.style.width=P+"px",B.style.height=P+"px",B.style.borderRadius="50%",B.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,l.appendChild(B);var A=document.createElement("div");A.style.boxSizing="inherit",A.style.width=H+"px",A.style.height=F+"px",A.style.borderRadius="50%",A.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.marginTop=-(F/2+o.gyroscopeThickness)+"px",A.style.marginLeft=-(H/2+o.gyroscopeThickness)+"px",l.appendChild(A);var L=document.createElement("div");L.style.boxSizing="inherit",L.style.width=F+"px",L.style.height=H+"px",L.style.borderRadius="50%",L.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,L.style.position="absolute",L.style.top="50%",L.style.left="50%",L.style.marginTop=-(H/2+o.gyroscopeThickness)+"px",L.style.marginLeft=-(F/2+o.gyroscopeThickness)+"px",l.appendChild(L),e.addAction("device-orientation",d);break;case"virtual-reality":var O=o.buttonsHeight*o.virtualRealityRatio,D=O/4,X=D/2;l=document.createElement("div"),l.style.cssFloat="right",l.style.position="relative",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=O+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",i(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.boxSizing="inherit",W.style.width=O+"px",W.style.height=o.buttonsHeight+"px",W.style.borderRadius=o.virtualRealityBorderRadius+"px",W.style.backgroundColor=o.buttonsColor,l.appendChild(W);var N=document.createElement("div");N.style.boxSizing="inherit",N.style.width=D+"px",N.style.height=D+"px",N.style.position="absolute",N.style.top=X+10+"px",N.style.left=X+10+"px",N.style.borderRadius="50%",N.style.backgroundColor=o.backgroundColor,l.appendChild(N);var $=document.createElement("div");$.style.boxSizing="inherit",$.style.width=D+"px",$.style.height=D+"px",$.style.position="absolute",$.style.top=X+10+"px",$.style.right=X+10+"px",$.style.borderRadius="50%",$.style.backgroundColor=o.backgroundColor,l.appendChild($);var q=document.createElement("div");q.style.boxSizing="inherit",q.style.width=D+"px",q.style.height=o.buttonsHeight/2+"px",q.style.position="absolute",q.style.left="50%",q.style.bottom="10px",q.style.marginLeft=-(D/2)+"px",q.style.borderTopLeftRadius="50% 60%",q.style.borderTopRightRadius="50% 60%",q.style.backgroundColor=o.backgroundColor,l.appendChild(q),e.addAction("stereo-effect",d)}};this.getButton=function(){return l};var r,a,s,l,d=function(e){e?l.style.backgroundColor=o.activeButtonsBackgroundColor:l.style.backgroundColor=o.buttonsBackgroundColor},c=function(e){s.style.left=e/100*o.zoomRangeWidth-o.zoomRangeDisk/2+"px"},u=function(e){p(parseInt(e.clientX))},h=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&p(parseInt(t.clientX))},p=function(e){y=!0,f(e)},g=function(e){y=!1},v=function(e){e.preventDefault(),f(parseInt(e.clientX))},m=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),f(parseInt(t.clientX)))},f=function(t){if(y){var i=t-a.getBoundingClientRect().left,n=i/o.zoomRangeWidth*100;e.zoom(n)}},y=!1;n()},Sphoords=function(){var e=function(){var e=navigator.userAgent;return/Gecko\/[0-9.]+/.test(e)?"Gecko":/Chrome\/[0-9.]+/.test(e)?"Blink":/AppleWebKit\/[0-9.]+/.test(e)?"WebKit":/Trident\/[0-9.]+/.test(e)?"Trident":/Opera\/[0-9.]+/.test(e)?"Presto":"Gecko"},t=function(e){return e-360*Math.floor(e/360)};this.start=function(){return Sphoords.isDeviceOrientationSupported?(window.addEventListener("deviceorientation",o,!1),n=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){n&&(window.removeEventListener("deviceorientation",o,!1),n=!1)},this.toggle=function(){n?this.stop():this.start()},this.isEventAttached=function(){return n};var o=function(e){c=Sphoords.getScreenOrientation();var o=0,n=0;switch(c){case"portrait-primary":o=e.alpha+e.gamma,n=e.beta-90;break;case"landscape-primary":if(o=e.alpha+e.beta-90,n=-e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":n+=180;break;case"Gecko":default:n=-n}break;case"landscape-secondary":if(o=e.alpha-e.beta+90,n=e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":n+=180;break;case"Gecko":default:n=-n}break;case"portrait-secondary":o=e.alpha-e.gamma,n=180-(e.beta-90),n=270-e.beta}n=t(n),n>=180&&(n-=360),r=t(o),a=Math.max(-90,Math.min(90,n)),s=r*d,l=a*d,i()};this.getCoordinates=function(){return{longitude:s,latitude:l}},this.getCoordinatesInDegrees=function(){return{longitude:r,latitude:a}},this.getScreenOrientation=function(){return c},this.addListener=function(e){h.push(e)};var i=function(){if(h.length)for(var e=0,t=h.length;t>e;++e)h[e]({longitude:s,latitude:l})},n=!1,r=0,a=0,s=0,l=0,d=Math.PI/180,c=Sphoords.getScreenOrientation(),u=e(),h=[]};Sphoords.getScreenOrientation=function(){var e=null;return screen.orientation?e=screen.orientation:screen.mozOrientation?e=screen.mozOrientation:screen.msOrientation&&(e=screen.msOrientation),null!==e&&"object"==typeof e?e.type:e},Sphoords.isDeviceOrientationSupported=!1,function(){function e(t){null!==t&&null!==t.alpha&&(Sphoords.isDeviceOrientationSupported=!0,window.removeEventListener("deviceorientation",e))}window.DeviceOrientationEvent&&null!==Sphoords.getScreenOrientation()&&window.addEventListener("deviceorientation",e)}(); \ No newline at end of file diff --git a/src/PhotoSphereViewer.js b/src/PhotoSphereViewer.js index 58898bafc..b38e8c2c1 100644 --- a/src/PhotoSphereViewer.js +++ b/src/PhotoSphereViewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.6 + * Photo Sphere Viewer v2.7 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine