mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
fix .close() called after .destroy() + spacing
This commit is contained in:
parent
764fa3e34a
commit
a563bdb658
@ -306,15 +306,16 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the drawer (unload current loaded tiles)
|
* Destroy the drawer (unload current loaded tiles)
|
||||||
|
* @method
|
||||||
|
* @return null
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
|
||||||
//unload current loaded tiles (=empty TILE_CACHE)
|
//unload current loaded tiles (=empty TILE_CACHE)
|
||||||
for (var i=0; i<this.tilesLoaded.length; ++i) {
|
for ( var i = 0; i < this.tilesLoaded.length; ++i ) {
|
||||||
this.tilesLoaded[i].unload();
|
this.tilesLoaded[i].unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
//force unloading of current canvas (1x1 will be gc later, trick not necessary needed)
|
//force unloading of current canvas (1x1 will be gc later, trick not necessarily needed)
|
||||||
this.canvas.width = 1;
|
this.canvas.width = 1;
|
||||||
this.canvas.height = 1;
|
this.canvas.height = 1;
|
||||||
}
|
}
|
||||||
|
@ -529,6 +529,12 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
* @fires OpenSeadragon.Viewer.event:close
|
* @fires OpenSeadragon.Viewer.event:close
|
||||||
*/
|
*/
|
||||||
close: function ( ) {
|
close: function ( ) {
|
||||||
|
|
||||||
|
if ( !THIS[ this.hash ] ) {
|
||||||
|
//this viewer has already been destroyed: returning immediately
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
if ( this._updateRequestId !== null ) {
|
if ( this._updateRequestId !== null ) {
|
||||||
$.cancelAnimationFrame( this._updateRequestId );
|
$.cancelAnimationFrame( this._updateRequestId );
|
||||||
this._updateRequestId = null;
|
this._updateRequestId = null;
|
||||||
@ -542,7 +548,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
this.drawersContainer.innerHTML = "";
|
this.drawersContainer.innerHTML = "";
|
||||||
this.overlaysContainer.innerHTML = "";
|
this.overlaysContainer.innerHTML = "";
|
||||||
|
|
||||||
if (this.drawer) {
|
if ( this.drawer ) {
|
||||||
this.drawer.destroy();
|
this.drawer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,6 +585,10 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
destroy: function( ) {
|
destroy: function( ) {
|
||||||
this.close();
|
this.close();
|
||||||
|
|
||||||
|
//TODO: implement this...
|
||||||
|
//this.unbindSequenceControls()
|
||||||
|
//this.unbindStandardControls()
|
||||||
|
|
||||||
this.removeAllHandlers();
|
this.removeAllHandlers();
|
||||||
|
|
||||||
// Go through top element (passed to us) and remove all children
|
// Go through top element (passed to us) and remove all children
|
||||||
|
@ -295,6 +295,7 @@
|
|||||||
equal(null, viewer.container);
|
equal(null, viewer.container);
|
||||||
equal(null, viewer.element);
|
equal(null, viewer.element);
|
||||||
equal(true, closeCalled);
|
equal(true, closeCalled);
|
||||||
|
viewer = null;
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>OpenSeadragon Memory Check Demo</title>
|
|
||||||
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
|
||||||
<style type="text/css">
|
|
||||||
|
|
||||||
.openseadragon1 {
|
|
||||||
width: 800px;
|
|
||||||
height: 600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
Simple demo page to monitor OpenSeadragon Memory Usage.
|
|
||||||
</div>
|
|
||||||
<button onclick="createViewer()">Create</button>
|
|
||||||
<button onclick="destroyViewer()">Destroy</button>
|
|
||||||
|
|
||||||
<div id="contentDiv" class="openseadragon1"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
var _viewer;
|
|
||||||
|
|
||||||
var generateUniqueHash = (function() {
|
|
||||||
var counter = 0;
|
|
||||||
return function() {
|
|
||||||
return "seadragon_"+(counter++);
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
function createViewer() {
|
|
||||||
if (_viewer) {
|
|
||||||
destroyViewer();
|
|
||||||
}
|
|
||||||
|
|
||||||
_viewer = OpenSeadragon({
|
|
||||||
element: document.getElementById("contentDiv"),
|
|
||||||
showNavigationControl: false,
|
|
||||||
springStiffness: 20,
|
|
||||||
animationTime : 1.5,
|
|
||||||
visibilityRatio: 1,
|
|
||||||
hash: "hello",
|
|
||||||
tileSources: {
|
|
||||||
Image: {
|
|
||||||
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
|
|
||||||
Url: 'http://cdn.photosynth.net/ps2/92fe5de9-dffa-4315-9095-082da8b90642/packet/undistorted/img0014/',
|
|
||||||
Format: "jpg",
|
|
||||||
Overlap: 1,
|
|
||||||
TileSize: 510,
|
|
||||||
Size: {
|
|
||||||
Width: 4592,
|
|
||||||
Height: 3448
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroyViewer() {
|
|
||||||
if (_viewer) {
|
|
||||||
_viewer.destroy();
|
|
||||||
}
|
|
||||||
_viewer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
57
test/demo/memorycheck.html
Normal file
57
test/demo/memorycheck.html
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OpenSeadragon Memory Check Demo</title>
|
||||||
|
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
.openseadragon1 {
|
||||||
|
width: 800px;
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
Simple demo page to monitor OpenSeadragon Memory Usage.
|
||||||
|
</div>
|
||||||
|
<button onclick="createViewer()">Create</button>
|
||||||
|
<button onclick="destroyViewer()">Destroy</button>
|
||||||
|
|
||||||
|
<div id="contentDiv" class="openseadragon1"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var _viewer;
|
||||||
|
|
||||||
|
var generateUniqueHash = (function() {
|
||||||
|
var counter = 0;
|
||||||
|
return function() {
|
||||||
|
return "openseadragon_" + (counter++);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
function createViewer() {
|
||||||
|
if ( _viewer ) {
|
||||||
|
destroyViewer();
|
||||||
|
}
|
||||||
|
|
||||||
|
_viewer = OpenSeadragon({
|
||||||
|
element: document.getElementById("contentDiv"),
|
||||||
|
showNavigationControl: false,
|
||||||
|
prefixUrl: "../../build/openseadragon/images/",
|
||||||
|
hash: generateUniqueHash(), //this is only needed if you want to instantiate more than one viewer at a time.
|
||||||
|
tileSources: "../data/testpattern.dzi"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyViewer() {
|
||||||
|
if ( _viewer ) {
|
||||||
|
_viewer.destroy();
|
||||||
|
}
|
||||||
|
_viewer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user