diff --git a/src/viewer.js b/src/viewer.js index d963bf14..748137fe 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -756,6 +756,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, * viewer = null; //important * * @function + * @fires OpenSeadragon.Viewer.event:before-destroy + * @fires OpenSeadragon.Viewer.event:destroy */ destroy: function( ) { if ( !THIS[ this.hash ] ) { @@ -763,6 +765,17 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, return; } + /** + * Raised when the viewer is about to be destroyed (see {@link OpenSeadragon.Viewer#before-destroy}). + * + * @event before-destroy + * @memberof OpenSeadragon.Viewer + * @type {object} + * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ + this.raiseEvent( 'before-destroy' ); + this._removeUpdatePixelDensityRatioEvent(); this.close(); @@ -795,7 +808,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, this.navigator = null; } - this.removeAllHandlers(); if (this.buttonGroup) { this.buttonGroup.destroy(); @@ -841,6 +853,19 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, // clear our reference to the main element - they will need to pass it in again, creating a new viewer this.element = null; + + /** + * Raised when the viewer is destroyed (see {@link OpenSeadragon.Viewer#destroy}). + * + * @event destroy + * @memberof OpenSeadragon.Viewer + * @type {object} + * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ + this.raiseEvent( 'destroy' ); + + this.removeAllHandlers(); }, /** diff --git a/src/viewport.js b/src/viewport.js index ae951eba..137f2aa0 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -514,7 +514,7 @@ $.Viewport.prototype = { * @param {OpenSeadragon.Rect} bounds * @returns {OpenSeadragon.Rect} constrained bounds. */ - _applyBoundaryConstraints: function(bounds) { + _applyBoundaryConstraints: function(bounds) { var newBounds = new $.Rect( bounds.x, bounds.y,