mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-20 09:41:45 +03:00
Merge pull request #80 from bgilbert/timer-leak
Fix updateMulti timer leak after multiple Viewer.open() calls. Fixes #76
This commit is contained in:
commit
9d864c07b1
@ -6,21 +6,13 @@
|
|||||||
// pythons gettext might be a reasonable approach.
|
// pythons gettext might be a reasonable approach.
|
||||||
var I18N = {
|
var I18N = {
|
||||||
Errors: {
|
Errors: {
|
||||||
Failure: "Sorry, but Seadragon Ajax can't run on your browser!\n" +
|
|
||||||
"Please try using IE 7 or Firefox 3.\n",
|
|
||||||
Dzc: "Sorry, we don't support Deep Zoom Collections!",
|
Dzc: "Sorry, we don't support Deep Zoom Collections!",
|
||||||
Dzi: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
Dzi: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
||||||
Xml: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
Xml: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
||||||
Empty: "You asked us to open nothing, so we did just that.",
|
|
||||||
ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.",
|
ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.",
|
||||||
Security: "It looks like a security restriction stopped us from " +
|
Security: "It looks like a security restriction stopped us from " +
|
||||||
"loading this Deep Zoom Image.",
|
"loading this Deep Zoom Image.",
|
||||||
Status: "This space unintentionally left blank ({0} {1}).",
|
Status: "This space unintentionally left blank ({0} {1})."
|
||||||
Unknown: "Whoops, something inexplicably went wrong. Sorry!"
|
|
||||||
},
|
|
||||||
|
|
||||||
Messages: {
|
|
||||||
Loading: "Loading..."
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Tooltips: {
|
Tooltips: {
|
||||||
|
@ -115,8 +115,7 @@ $.Viewer = function( options ) {
|
|||||||
THIS[ this.hash ] = {
|
THIS[ this.hash ] = {
|
||||||
"fsBoundsDelta": new $.Point( 1, 1 ),
|
"fsBoundsDelta": new $.Point( 1, 1 ),
|
||||||
"prevContainerSize": null,
|
"prevContainerSize": null,
|
||||||
"lastOpenStartTime": 0,
|
"updateRequestId": null,
|
||||||
"lastOpenEndTime": 0,
|
|
||||||
"animating": false,
|
"animating": false,
|
||||||
"forceRedraw": false,
|
"forceRedraw": false,
|
||||||
"mouseInside": false,
|
"mouseInside": false,
|
||||||
@ -355,6 +354,10 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
|
|||||||
* @return {OpenSeadragon.Viewer} Chainable.
|
* @return {OpenSeadragon.Viewer} Chainable.
|
||||||
*/
|
*/
|
||||||
close: function ( ) {
|
close: function ( ) {
|
||||||
|
if ( THIS[ this.hash ].updateRequestId !== null ){
|
||||||
|
$.cancelAnimationFrame( THIS[ this.hash ].updateRequestId );
|
||||||
|
THIS[ this.hash ].updateRequestId = null;
|
||||||
|
}
|
||||||
|
|
||||||
if( this.drawer ){
|
if( this.drawer ){
|
||||||
this.drawer.clearOverlays();
|
this.drawer.clearOverlays();
|
||||||
@ -956,16 +959,6 @@ function openTileSource( viewer, source ) {
|
|||||||
_this.close( );
|
_this.close( );
|
||||||
}
|
}
|
||||||
|
|
||||||
// to ignore earlier opens
|
|
||||||
THIS[ _this.hash ].lastOpenStartTime = +new Date();
|
|
||||||
|
|
||||||
window.setTimeout( function () {
|
|
||||||
if ( THIS[ _this.hash ].lastOpenStartTime > THIS[ _this.hash ].lastOpenEndTime ) {
|
|
||||||
THIS[ _this.hash ].setMessage( $.getString( "Messages.Loading" ) );
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
THIS[ _this.hash ].lastOpenEndTime = +new Date();
|
|
||||||
_this.canvas.innerHTML = "";
|
_this.canvas.innerHTML = "";
|
||||||
THIS[ _this.hash ].prevContainerSize = $.getElementSize( _this.container );
|
THIS[ _this.hash ].prevContainerSize = $.getElementSize( _this.container );
|
||||||
|
|
||||||
@ -1076,7 +1069,7 @@ function openTileSource( viewer, source ) {
|
|||||||
|
|
||||||
THIS[ _this.hash ].animating = false;
|
THIS[ _this.hash ].animating = false;
|
||||||
THIS[ _this.hash ].forceRedraw = true;
|
THIS[ _this.hash ].forceRedraw = true;
|
||||||
scheduleUpdate( _this, updateMulti );
|
THIS[ _this.hash ].updateRequestId = scheduleUpdate( _this, updateMulti );
|
||||||
|
|
||||||
//Assuming you had programatically created a bunch of overlays
|
//Assuming you had programatically created a bunch of overlays
|
||||||
//and added them via configuration
|
//and added them via configuration
|
||||||
@ -1351,12 +1344,15 @@ function updateMulti( viewer ) {
|
|||||||
var beginTime;
|
var beginTime;
|
||||||
|
|
||||||
if ( !viewer.source ) {
|
if ( !viewer.source ) {
|
||||||
|
THIS[ viewer.hash ].updateRequestId = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginTime = +new Date();
|
beginTime = +new Date();
|
||||||
updateOnce( viewer );
|
updateOnce( viewer );
|
||||||
scheduleUpdate( viewer, arguments.callee, beginTime );
|
|
||||||
|
THIS[ viewer.hash ].updateRequestId = scheduleUpdate( viewer,
|
||||||
|
arguments.callee, beginTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOnce( viewer ) {
|
function updateOnce( viewer ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user