Merge branch 'master' into ig-loading

This commit is contained in:
Ian Gilman 2017-07-06 10:06:07 -07:00
commit 2419a0111a
8 changed files with 185 additions and 29 deletions

View File

@ -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:

View File

@ -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(

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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.');
}
}
});

View File

@ -10,6 +10,11 @@
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script>
var isCoverageTest = true;
</script>
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
<script src="/test/lib/jquery-1.9.1.min.js"></script>
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>OpenSeadragon Basic Demo</title>
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
<style type="text/css">
.openseadragon1 {
width: 800px;
height: 600px;
}
</style>
</head>
<body>
<div>
Turn debug mode on and off after viewer has been created.
<button onclick="debugModeOn()">Debug Mode On</button>
<button onclick="debugModeOff()">Debug Mode Off</button>
</div>
<div id="contentDiv" class="openseadragon1"></div>
<script type="text/javascript">
var viewer = OpenSeadragon({
// debugMode: true,
id: "contentDiv",
prefixUrl: "../../build/openseadragon/images/",
tileSources: "../data/testpattern.dzi",
showNavigator: true,
debugMode: true
});
function debugModeOn() {
viewer.setDebugMode(true);
}
function debugModeOff() {
viewer.setDebugMode(false);
}
</script>
</body>
</html>

View File

@ -424,11 +424,47 @@
} );
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");
});
}
})();