diff --git a/README.md b/README.md index 28aae1c9..757ea619 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,8 @@ When contributing, please attempt to match the code style already in the codebas When fixing bugs and adding features, when appropriate please also: -* Update changelog.txt -* Add/update related unit tests * Update related doc comments +* Add/update related unit tests If you're new to the project, check out our [good first bug](https://github.com/openseadragon/openseadragon/issues?labels=good+first+bug&page=1&state=open) issues for some places to dip your toe in the water. diff --git a/changelog.txt b/changelog.txt index 9e696ade..e87729b5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,6 +9,10 @@ OPENSEADRAGON CHANGELOG * Keyboard handling is now done in the viewer rather than navigator (#46) * Additional navigator fixes (#46) * Fixed an error in EventHandler.removeHandler() (#48) +* Better requestAnimationFrame detection on older Firefox (#103) +* More efficient navigator loading (#115) +* Sometimes tiles wouldn't resolve if you used the blendTime option; fixed. (#95) +* You can now choose to have previous and next buttons wrap using the config.navPrevNextWrap. (#114) 0.9.127: diff --git a/src/button.js b/src/button.js index 88c73274..32e15950 100644 --- a/src/button.js +++ b/src/button.js @@ -57,7 +57,7 @@ $.ButtonState = { * @param {String} options.srcRest URL of image to use in 'rest' state * @param {String} options.srcGroup URL of image to use in 'up' state * @param {String} options.srcHover URL of image to use in 'hover' state - * @param {String} options.srcDown URL of image to use in 'domn' state + * @param {String} options.srcDown URL of image to use in 'down' state * @param {Element} [options.element] Element to use as a container for the * button. * @property {String} tooltip Provides context help for the button we the @@ -65,7 +65,7 @@ $.ButtonState = { * @property {String} srcRest URL of image to use in 'rest' state * @property {String} srcGroup URL of image to use in 'up' state * @property {String} srcHover URL of image to use in 'hover' state - * @property {String} srcDown URL of image to use in 'domn' state + * @property {String} srcDown URL of image to use in 'down' state * @property {Object} config Configurable settings for this button. DEPRECATED. * @property {Element} [element] Element to use as a container for the * button. diff --git a/src/drawer.js b/src/drawer.js index 72c932d5..833d1fe6 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -709,8 +709,7 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le ); if ( tile.loaded ) { - - drawer.updateAgain = blendTile( + var needsUpdate = blendTile( drawer, tile, x, y, @@ -718,6 +717,10 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le levelOpacity, currentTime ); + + if ( needsUpdate ) { + drawer.updateAgain = true; + } } else if ( tile.loading ) { // the tile is already in the download queue // thanks josh1093 for finally translating this typo diff --git a/src/openseadragon.js b/src/openseadragon.js index 6ed7c3af..8e3b41be 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -258,6 +258,11 @@ * these paths, prefer setting the option.prefixUrl rather than overriding * every image path directly through this setting. * + * @param {Boolean} [options.navPrevNextWrap=false] + * If the 'previous' button will wrap to the last image when viewing the first + * image and if the 'next' button will wrap to the first image when viewing + * the last image. + * * @returns {OpenSeadragon.Viewer} */ window.OpenSeadragon = window.OpenSeadragon || function( options ){ @@ -595,6 +600,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ DOWN: 'next_pressed.png' } }, + navPrevNextWrap: false, //DEVELOPER SETTINGS debugMode: false, diff --git a/src/viewer.js b/src/viewer.js index 0ec5b19e..624431e4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -346,6 +346,10 @@ $.Viewer = function( options ) { beginControlsAutoHide( _this ); } ); // initial fade out + if(this.navPrevNextWrap){ + this.previousButton.enable(); + } + }; $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, { @@ -523,8 +527,11 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, /** + * Shows or hides the controls (e.g. the default navigation buttons). + * * @function - * @name OpenSeadragon.Viewer.prototype.setDashboardEnabled + * @name OpenSeadragon.Viewer.prototype.setControlsEnabled + * @param {Boolean} true to show, false to hide. * @return {OpenSeadragon.Viewer} Chainable. */ setControlsEnabled: function( enabled ) { @@ -1019,7 +1026,9 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, if( this.nextButton ){ if( ( this.tileSources.length - 1 ) === page ){ //Disable next button - this.nextButton.disable(); + if(!this.navPrevNextWrap){ + this.nextButton.disable(); + } } else { this.nextButton.enable(); } @@ -1029,7 +1038,9 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, //Enable previous button this.previousButton.enable(); } else { - this.previousButton.disable(); + if(!this.navPrevNextWrap){ + this.previousButton.disable(); + } } } @@ -1145,7 +1156,10 @@ function openTileSource( viewer, source ) { sizeRatio: _this.navigatorSizeRatio, height: _this.navigatorHeight, width: _this.navigatorWidth, - tileSources: _this.tileSources, + // By passing the fully parsed source here, the navigator doesn't + // have to load it again. Additionally, we don't have to call + // navigator.open, as it's implicitly called in the ctor. + tileSources: source, tileHost: _this.tileHost, prefixUrl: _this.prefixUrl, overlays: _this.overlays, @@ -1210,10 +1224,6 @@ function openTileSource( viewer, source ) { } VIEWERS[ _this.hash ] = _this; - if( _this.navigator ){ - _this.navigator.open( source ); - } - _this.raiseEvent( 'open', { source: source, viewer: _this } ); return _this; @@ -1623,12 +1633,18 @@ function onFullPage() { function onPrevious(){ var previous = THIS[ this.hash ].sequence - 1; + if(this.navPrevNextWrap && previous < 0){ + previous += this.tileSources.length; + } this.goToPage( previous ); } function onNext(){ var next = THIS[ this.hash ].sequence + 1; + if(this.navPrevNextWrap && next >= this.tileSources.length){ + next = 0; + } this.goToPage( next ); }