Compare commits

...

7 Commits

Author SHA1 Message Date
Ian Gilman
11f70d54e8 Changelog for #2239 2022-11-29 13:53:35 -08:00
Ian Gilman
b8cc7e171e
Merge pull request #2239 from pearcetm/viewer-destroy-event
Viewer destroy event
2022-11-29 13:51:48 -08:00
Tom
554149cf4f merged .gitignore changes 2022-11-28 17:56:05 -05:00
Tom
968cb96bc4 added before-destroy event; reverted viewport boundary constraint changes 2022-11-28 17:54:23 -05:00
Tom
6fa8e6695d viewport _applyBoundaryConstraints fix 2022-11-26 12:04:05 -05:00
Tom
27399beffe banish .DS_Store 2022-11-23 15:33:09 -05:00
Tom
29384cd5ff Added event for viewer destroy 2022-11-23 15:28:40 -05:00
3 changed files with 28 additions and 2 deletions

View File

@ -11,6 +11,7 @@ OPENSEADRAGON CHANGELOG
* You can now provide an element for the navigator (as an alternative to an ID) (#1303 @cameronbaney, #2166 #2175 @joedf) * You can now provide an element for the navigator (as an alternative to an ID) (#1303 @cameronbaney, #2166 #2175 @joedf)
* Now supporting IIIF "id" and "identifier" in addition to "@id" (#2173 @ahankinson) * Now supporting IIIF "id" and "identifier" in addition to "@id" (#2173 @ahankinson)
* We now delegate tile fetching and caching to the TileSource, to allow for custom tile formats (#2148 @Aiosa) * We now delegate tile fetching and caching to the TileSource, to allow for custom tile formats (#2148 @Aiosa)
* The viewer now emits before-destroy and destroy events (#2239 @pearcetm)
* Improved documentation (#2211 @shyamkumaryadav) * Improved documentation (#2211 @shyamkumaryadav)
* Fixed: Cropping tiled images with polygons was broken (#2183 @altert) * Fixed: Cropping tiled images with polygons was broken (#2183 @altert)
* Fixed: Disabling buttons only changed their appearance, but they were still clickable (#2187 @pearcetm) * Fixed: Disabling buttons only changed their appearance, but they were still clickable (#2187 @pearcetm)

View File

@ -756,6 +756,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
* viewer = null; //important * viewer = null; //important
* *
* @function * @function
* @fires OpenSeadragon.Viewer.event:before-destroy
* @fires OpenSeadragon.Viewer.event:destroy
*/ */
destroy: function( ) { destroy: function( ) {
if ( !THIS[ this.hash ] ) { if ( !THIS[ this.hash ] ) {
@ -763,6 +765,17 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
return; 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._removeUpdatePixelDensityRatioEvent();
this.close(); this.close();
@ -795,7 +808,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.navigator = null; this.navigator = null;
} }
this.removeAllHandlers();
if (this.buttonGroup) { if (this.buttonGroup) {
this.buttonGroup.destroy(); 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 // clear our reference to the main element - they will need to pass it in again, creating a new viewer
this.element = null; 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();
}, },
/** /**

View File

@ -514,7 +514,7 @@ $.Viewport.prototype = {
* @param {OpenSeadragon.Rect} bounds * @param {OpenSeadragon.Rect} bounds
* @returns {OpenSeadragon.Rect} constrained bounds. * @returns {OpenSeadragon.Rect} constrained bounds.
*/ */
_applyBoundaryConstraints: function(bounds) { _applyBoundaryConstraints: function(bounds) {
var newBounds = new $.Rect( var newBounds = new $.Rect(
bounds.x, bounds.x,
bounds.y, bounds.y,