mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Merge pull request #1832 from JoFrMueller/pr-1721
Clear viewer and navigator listeners and nodes to avoid memory leaks
This commit is contained in:
commit
df850c62e8
@ -396,6 +396,20 @@ $.extend( $.Button.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.
|
|||||||
this.element.disabled = false;
|
this.element.disabled = false;
|
||||||
$.setElementOpacity( this.element, 1.0, true );
|
$.setElementOpacity( this.element, 1.0, true );
|
||||||
this.notifyGroupEnter();
|
this.notifyGroupEnter();
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.element.removeChild(this.imgRest);
|
||||||
|
this.imgRest = null;
|
||||||
|
this.element.removeChild(this.imgGroup);
|
||||||
|
this.imgGroup = null;
|
||||||
|
this.element.removeChild(this.imgHover);
|
||||||
|
this.imgHover = null;
|
||||||
|
this.element.removeChild(this.imgDown);
|
||||||
|
this.imgDown = null;
|
||||||
|
this.removeAllHandlers();
|
||||||
|
this.tracker.destroy();
|
||||||
|
this.element = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -129,6 +129,16 @@ $.ButtonGroup.prototype = {
|
|||||||
*/
|
*/
|
||||||
emulateExit: function() {
|
emulateExit: function() {
|
||||||
this.tracker.exitHandler( { eventSource: this.tracker } );
|
this.tracker.exitHandler( { eventSource: this.tracker } );
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
while (this.buttons.length) {
|
||||||
|
var button = this.buttons.pop();
|
||||||
|
this.element.removeChild(button.element);
|
||||||
|
button.destroy();
|
||||||
|
}
|
||||||
|
this.tracker.destroy();
|
||||||
|
this.element = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -406,6 +406,10 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
|
|||||||
return $.Viewer.prototype.addTiledImage.apply(this, [optionsClone]);
|
return $.Viewer.prototype.addTiledImage.apply(this, [optionsClone]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
return $.Viewer.prototype.destroy.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
_getMatchingItem: function(theirItem) {
|
_getMatchingItem: function(theirItem) {
|
||||||
var count = this.world.getItemCount();
|
var count = this.world.getItemCount();
|
||||||
|
@ -765,8 +765,23 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
this.drawer.destroy();
|
this.drawer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.navigator ) {
|
||||||
|
this.navigator.destroy();
|
||||||
|
THIS[ this.navigator.hash ] = null;
|
||||||
|
delete THIS[ this.navigator.hash ];
|
||||||
|
this.navigator = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.removeAllHandlers();
|
this.removeAllHandlers();
|
||||||
|
|
||||||
|
if (this.buttons) {
|
||||||
|
this.buttons.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.paging) {
|
||||||
|
this.paging.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// Go through top element (passed to us) and remove all children
|
// Go through top element (passed to us) and remove all children
|
||||||
// Use removeChild to make sure it handles SVG or any non-html
|
// Use removeChild to make sure it handles SVG or any non-html
|
||||||
// also it performs better - http://jsperf.com/innerhtml-vs-removechild/15
|
// also it performs better - http://jsperf.com/innerhtml-vs-removechild/15
|
||||||
@ -776,6 +791,9 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.container.onsubmit = null;
|
||||||
|
this.clearControls();
|
||||||
|
|
||||||
// destroy the mouse trackers
|
// destroy the mouse trackers
|
||||||
if (this.innerTracker){
|
if (this.innerTracker){
|
||||||
this.innerTracker.destroy();
|
this.innerTracker.destroy();
|
||||||
@ -3261,7 +3279,7 @@ function updateOnce( viewer ) {
|
|||||||
|
|
||||||
//viewer.profiler.beginUpdate();
|
//viewer.profiler.beginUpdate();
|
||||||
|
|
||||||
if (viewer._opening) {
|
if (viewer._opening || !THIS[viewer.hash]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user