diff --git a/changelog.txt b/changelog.txt index edee4454..8d2e670c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -45,6 +45,13 @@ OPENSEADRAGON CHANGELOG * Fixed: setItemIndex method not working with navigator inside "open" event (#1201) * The navigator now picks up opacity and compositeOperation changes (#1203) * New events for opacity and compositeOperation changes (#1203) +* Fixed: The reference strip didn't show the initial page if it wasn't the first page (#1208) +* Added support for setting debug mode after the Viewer object has been constructed (#1224) +* Fixed: Sometimes the image would stick to the mouse when right-clicking and left-clicking simultaneously (#1223) +* Fixed issue with transparent images sometimes disappearing on Safari (#1222) +* Better calculation for TileCache release cutoff (#1214) +* Fixed: One image failing to load could cause the others to never load (#1229) +* Added functions for dynamically adding and removing the reference strip in sequence mode (#1213) 2.2.1: diff --git a/src/drawer.js b/src/drawer.js index 4485da98..eed97719 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -426,22 +426,22 @@ $.Drawer.prototype = { this.context.globalCompositeOperation = compositeOperation; } if (bounds) { - // Internet Explorer and Microsoft Edge throw IndexSizeError + // Internet Explorer, Microsoft Edge, and Safari have problems // when you call context.drawImage with negative x or y - // or width or height greater than the canvas width or height respectively + // or x + width or y + height greater than the canvas width or height respectively. if (bounds.x < 0) { bounds.width += bounds.x; bounds.x = 0; } - if (bounds.width > this.canvas.width) { - bounds.width = this.canvas.width; + if (bounds.x + bounds.width > this.canvas.width) { + bounds.width = this.canvas.width - bounds.x; } if (bounds.y < 0) { bounds.height += bounds.y; bounds.y = 0; } - if (bounds.height > this.canvas.height) { - bounds.height = this.canvas.height; + if (bounds.y + bounds.height > this.canvas.height) { + bounds.height = this.canvas.height - bounds.y; } this.context.drawImage( diff --git a/src/mousetracker.js b/src/mousetracker.js index 3dbcf595..d81f5561 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -2879,6 +2879,12 @@ } } + // A primary mouse button may have been released while the non-primary button was down + if (pointsList.contacts > 0 && pointsList.type === 'mouse') { + // Stop tracking the mouse; see https://github.com/openseadragon/openseadragon/pull/1223 + pointsList.contacts--; + return true; + } return false; } diff --git a/src/tiledimage.js b/src/tiledimage.js index 41e10369..12de4b5c 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1475,8 +1475,7 @@ function onTileLoad( tiledImage, tile, time, image, errorMsg, tileRequest ) { } var finish = function() { - var cutoff = Math.ceil( Math.log( - tiledImage.source.getTileWidth(tile.level) ) / Math.log( 2 ) ); + var cutoff = tiledImage.source.getClosestLevel(); setTileLoaded(tiledImage, tile, image, cutoff, tileRequest); }; diff --git a/src/viewer.js b/src/viewer.js index ded3ef4d..10e6e4a4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -519,17 +519,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this.open(this.tileSources[this._sequenceIndex]); if ( this.showReferenceStrip ){ - this.referenceStrip = new $.ReferenceStrip({ - id: this.referenceStripElement, - position: this.referenceStripPosition, - sizeRatio: this.referenceStripSizeRatio, - scroll: this.referenceStripScroll, - height: this.referenceStripHeight, - width: this.referenceStripWidth, - tileSources: this.tileSources, - prefixUrl: this.prefixUrl, - viewer: this - }); + this.addReferenceStrip(); } } @@ -858,6 +848,22 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, return this; }, + /** + * Turns debugging mode on or off for this viewer. + * + * @function + * @param {Boolean} true to turn debug on, false to turn debug off. + */ + setDebugMode: function(debugMode){ + + for (var i = 0; i < this.world.getItemCount(); i++) { + this.world.getItemAt(i).debugMode = debugMode; + } + + this.debugMode = debugMode; + this.forceRedraw(); + }, + /** * @function * @return {Boolean} @@ -1365,11 +1371,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this._loadQueue.push(myQueueItem); - getTileSourceImplementation( this, options.tileSource, options, function( tileSource ) { - - myQueueItem.tileSource = tileSource; - - // add everybody at the front of the queue that's ready to go + function processReadyItems() { var queueItem, tiledImage, optionsClone; while (_this._loadQueue.length) { queueItem = _this._loadQueue[0]; @@ -1455,9 +1457,20 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, }); } } + } + + getTileSourceImplementation( this, options.tileSource, options, function( tileSource ) { + + myQueueItem.tileSource = tileSource; + + // add everybody at the front of the queue that's ready to go + processReadyItems(); }, function( event ) { event.options = options; raiseAddItemFailed(event); + + // add everybody at the front of the queue that's ready to go + processReadyItems(); } ); }, @@ -2130,6 +2143,52 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, */ _cancelPendingImages: function() { this._loadQueue = []; + }, + + /** + * Removes the reference strip and disables displaying it. + * @function + */ + removeReferenceStrip: function() { + this.showReferenceStrip = false; + + if (this.referenceStrip) { + this.referenceStrip.destroy(); + this.referenceStrip = null; + } + }, + + /** + * Enables and displays the reference strip based on the currently set tileSources. + * Works only when the Viewer has sequenceMode set to true. + * @function + */ + addReferenceStrip: function() { + this.showReferenceStrip = true; + + if (this.sequenceMode) { + if (this.referenceStrip) { + return; + } + + if (this.tileSources.length && this.tileSources.length > 1) { + this.referenceStrip = new $.ReferenceStrip({ + id: this.referenceStripElement, + position: this.referenceStripPosition, + sizeRatio: this.referenceStripSizeRatio, + scroll: this.referenceStripScroll, + height: this.referenceStripHeight, + width: this.referenceStripWidth, + tileSources: this.tileSources, + prefixUrl: this.prefixUrl, + viewer: this + }); + + this.referenceStrip.setFocus( this._sequenceIndex ); + } + } else { + $.console.warn('Attempting to display a reference strip while "sequenceMode" is off.'); + } } }); diff --git a/test/coverage.html b/test/coverage.html index 7fda4329..36e2e056 100644 --- a/test/coverage.html +++ b/test/coverage.html @@ -10,6 +10,11 @@
+ + + diff --git a/test/demo/setdebugmode.html b/test/demo/setdebugmode.html new file mode 100644 index 00000000..838e62ca --- /dev/null +++ b/test/demo/setdebugmode.html @@ -0,0 +1,44 @@ + + + + + OpenSeadragon Basic Demo + + + + + + +
+ Turn debug mode on and off after viewer has been created. + + +
+
+ + + + diff --git a/test/modules/basic.js b/test/modules/basic.js index 7dc2a9ef..4cecce2a 100644 --- a/test/modules/basic.js +++ b/test/modules/basic.js @@ -424,11 +424,47 @@ } ); - test('version object', function() { - equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string"); - ok(OpenSeadragon.version.major >= 0, "major should be a positive number"); - ok(OpenSeadragon.version.minor >= 0, "minor should be a positive number"); - ok(OpenSeadragon.version.revision >= 0, "revision should be a positive number"); + + asyncTest('SetDebugMode', function() { + ok(viewer, 'Viewer exists'); + + var checkImageTilesDebugState = function (expectedState) { + + for (var i = 0; i < viewer.world.getItemCount(); i++) { + if(viewer.world.getItemAt(i).debugMode != expectedState) { + return false; + } + } + return true; + }; + + var openHandler = function(event) { + viewer.removeHandler('open', openHandler); + + //Ensure we start with debug mode turned off + viewer.setDebugMode(false); + ok(checkImageTilesDebugState(false), "All image tiles have debug mode turned off."); + ok(!viewer.debugMode, "Viewer debug mode is turned off."); + + //Turn debug mode on and check that the Viewer and all tiled images are in debug mode. + viewer.setDebugMode(true); + ok(checkImageTilesDebugState(true), "All image tiles have debug mode turned on."); + ok(viewer.debugMode, "Viewer debug mode is turned on."); + + start(); + }; + + viewer.addHandler('open', openHandler); + viewer.open('/test/data/testpattern.dzi'); }); + //Version numbers are injected by the build process, so skip version tests if we are only running code coverage + if(!window.isCoverageTest ){ + test('version object', function() { + equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string"); + ok(OpenSeadragon.version.major >= 0, "major should be a positive number"); + ok(OpenSeadragon.version.minor >= 0, "minor should be a positive number"); + ok(OpenSeadragon.version.revision >= 0, "revision should be a positive number"); + }); + } })();