From d4b02e1abaaf43716b75d11d9125401551b2efb9 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 26 Feb 2013 22:34:44 -0500 Subject: [PATCH] managed to get a more complete, though hacky, implementation of #3. the big sticky point was how firefox and safari beahved when switching between applications when already in full screen mode. because we didnt have an event listener for fullscreenchange, and because those browsers released full screen on application or window change (think alt+tab or cmd+tab), you would come back to a empty document. more work left here to make this worth merging into master --- src/openseadragon.js | 6 +++--- src/viewer.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index af41bf6a..43b465a1 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -481,7 +481,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ maxZoomLevel: null, //UI RESPONSIVENESS AND FEEL - springStiffness: 5.0, + springStiffness: 7.0, clickTimeThreshold: 300, clickDistThreshold: 5, zoomPerClick: 2.0, @@ -490,13 +490,13 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ animationTime: 1.5, blendTime: 1.5, alwaysBlend: false, - autoHideControls: true, - immediateRender: false, + immediateRender: true, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE preserveViewport: false, //SEQUENCE showNavigationControl: true, //ZOOM/HOME/FULL/SEQUENCE + autoHideControls: true, controlsFadeDelay: 2000, //ZOOM/HOME/FULL/SEQUENCE controlsFadeLength: 1500, //ZOOM/HOME/FULL/SEQUENCE mouseNavEnabled: true, //GENERAL MOUSE INTERACTIVITY diff --git a/src/viewer.js b/src/viewer.js index 445730a1..f63a5dfa 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -615,6 +615,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, docStyle = document.documentElement.style, containerStyle = this.element.style, canvasStyle = this.canvas.style, + _this = this, oldBounds, newBounds, viewer, @@ -626,10 +627,30 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if ( fullPage == this.isFullPage() ) { return; } + this.tmp = function( event ) { + // The event object doesn't carry information about the fullscreen state of the browser, + // but it is possible to retrieve it through the fullscreen API + if( (document.fullScreenElement && document.fullScreenElement !== null) || + (document.mozFullScreen || document.webkitIsFullScreen) ){ + console.log( document.webkitIsFullScreen ); + // The target of the event is always the document, + // but it is possible to retrieve the fullscreen element through the API + if( !_this.isFullPage() ){ + _this.setFullPage( true ); + } + } else { + _this.setFullPage( false ); + } + }; if ( fullPage ) { - + requestFullScreen( document.body ); + + + // Note that the API is still vendor-prefixed in browsers implementing it + document.addEventListener("mozfullscreenchange", this.tmp); + document.addEventListener("webkitfullscreenchange", this.tmp); this.bodyOverflow = bodyStyle.overflow; this.docOverflow = docStyle.overflow; @@ -698,7 +719,9 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, } else { - cancelFullScreen( document ); + // Note that the API is still vendor-prefixed in browsers implementing it + document.removeEventListener("mozfullscreenchange", this.tmp); + document.removeEventListener("webkitfullscreenchange", this.tmp); bodyStyle.overflow = this.bodyOverflow; docStyle.overflow = this.docOverflow; @@ -750,6 +773,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, // mouse will likely be outside now $.delegate( this, onContainerExit )(); + cancelFullScreen( document ); + } this.raiseEvent( 'fullpage', { fullpage: fullPage, viewer: this } ); @@ -1523,4 +1548,5 @@ function toggleFull() { return false; } + }( OpenSeadragon ));