Better handle destruction when navigator in custom location

This commit is contained in:
Steve Halasz 2020-09-10 17:40:30 -04:00
parent 4ab8cc7481
commit 8178687298
3 changed files with 28 additions and 10 deletions

View File

@ -399,14 +399,22 @@ $.extend( $.Button.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.
},
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;
if (this.imgRest) {
this.element.removeChild(this.imgRest);
this.imgRest = null;
}
if (this.imgGroup) {
this.element.removeChild(this.imgGroup);
this.imgGroup = null;
}
if (this.imgHover) {
this.element.removeChild(this.imgHover);
this.imgHover = null;
}
if (this.imgDown) {
this.element.removeChild(this.imgDown);
this.imgDown = null;
}
this.removeAllHandlers();
this.tracker.destroy();
this.element = null;

View File

@ -161,7 +161,9 @@ $.Control.prototype = {
*/
destroy: function() {
this.wrapper.removeChild( this.element );
this.container.removeChild( this.wrapper );
if (this.anchor !== $.ControlAnchor.NONE) {
this.container.removeChild(this.wrapper);
}
},
/**

View File

@ -775,7 +775,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.removeAllHandlers();
if (this.buttons) {
this.buttons.destroy();
if (this.buttons instanceof $.ButtonGroup) {
this.buttons.destroy();
} else {
while (this.buttons.length) {
this.buttons.pop().destroy();
}
}
}
if (this.paging) {
@ -1869,6 +1875,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
{anchor: this.navigationControlAnchor || $.ControlAnchor.TOP_LEFT}
);
}
} else {
this.buttons = buttons;
}
}