diff --git a/src/extensions/uv-seadragon-extension/Extension.ts b/src/extensions/uv-seadragon-extension/Extension.ts index 6756c0203..ab528bbff 100644 --- a/src/extensions/uv-seadragon-extension/Extension.ts +++ b/src/extensions/uv-seadragon-extension/Extension.ts @@ -252,7 +252,7 @@ class Extension extends BaseExtension implements ISeadragonExtension { $.subscribe(Commands.SEADRAGON_ANIMATION_FINISH, (e, viewer) => { if (this.centerPanel && this.centerPanel.currentBounds){ - this.setParam(Params.xywh, this.centerPanel.getViewportBounds()); + this.setParam(Params.xywh, this.centerPanel.getViewportBounds().toString()); } var canvas: Manifesto.ICanvas = this.helper.getCurrentCanvas(); @@ -489,7 +489,10 @@ class Extension extends BaseExtension implements ISeadragonExtension { getViewportBounds(): string { if (!this.centerPanel) return null; const bounds = this.centerPanel.getViewportBounds(); - return bounds; + if (bounds) { + return bounds.toString(); + } + return null; } getViewerRotation(): number{ diff --git a/src/modules/uv-seadragoncenterpanel-module/SeadragonCenterPanel.ts b/src/modules/uv-seadragoncenterpanel-module/SeadragonCenterPanel.ts index a08db44f9..71f19d106 100644 --- a/src/modules/uv-seadragoncenterpanel-module/SeadragonCenterPanel.ts +++ b/src/modules/uv-seadragoncenterpanel-module/SeadragonCenterPanel.ts @@ -499,37 +499,7 @@ class SeadragonCenterPanel extends CenterPanel { $.publish(Commands.SEADRAGON_OPEN); - // check for initial zoom/rotation params. - if (this.isFirstLoad) { - - this.initialRotation = this.extension.getParam(Params.rotation); - - if (this.initialRotation){ - this.viewer.viewport.setRotation(parseInt(this.initialRotation)); - } - - this.initialBounds = this.extension.getParam(Params.xywh); - - if (this.initialBounds) { - this.initialBounds = Bounds.fromString(this.initialBounds); - this.currentBounds = this.initialBounds; - - this.fitToBounds(this.currentBounds); - - } else { - this.goHome(); - } - } else { - // it's not the first load - var settings: ISettings = this.extension.getSettings(); - - // zoom to bounds unless setting disabled - if (settings.preserveViewport && this.currentBounds){ - this.fitToBounds(this.currentBounds); - } else { - this.goHome(); - } - } + if (this.extension.helper.isMultiCanvas() && !this.extension.helper.isContinuous()) { @@ -568,10 +538,8 @@ class SeadragonCenterPanel extends CenterPanel { } this.setNavigatorVisible(); - - this.isFirstLoad = false; - this.overlaySearchResults(); + this.updateBounds(); let searchResultRect: SearchResultRect = this.getInitialSearchResultRect(); @@ -581,6 +549,35 @@ class SeadragonCenterPanel extends CenterPanel { if (searchResultRect && this.isZoomToSearchResultEnabled()) { this.zoomToSearchResult(searchResultRect); } + + this.isFirstLoad = false; + } + + updateBounds(): void { + + const settings: ISettings = this.extension.getSettings(); + + // if this is the first load and there are initial bounds, fit to those. + if (this.isFirstLoad) { + + this.initialRotation = this.extension.getParam(Params.rotation); + + if (this.initialRotation) { + this.viewer.viewport.setRotation(parseInt(this.initialRotation)); + } + + this.initialBounds = this.extension.getParam(Params.xywh); + + if (this.initialBounds) { + this.initialBounds = Bounds.fromString(this.initialBounds); + this.currentBounds = this.initialBounds; + this.fitToBounds(this.currentBounds); + } + } else if (settings.preserveViewport) { // if this isn't the first load and preserveViewport is enabled, fit to the current bounds. + this.fitToBounds(this.currentBounds); + } else { + this.goHome(); + } } goHome(): void { @@ -652,14 +649,14 @@ class SeadragonCenterPanel extends CenterPanel { return bounds.toString(); } - getViewportBounds(): string { + getViewportBounds(): Bounds { if (!this.viewer || !this.viewer.viewport) return null; const b: any = this.viewer.viewport.getBounds(true); const bounds: Bounds = new Bounds(Math.floor(b.x), Math.floor(b.y), Math.floor(b.width), Math.floor(b.height)); - return bounds.toString(); + return bounds; } viewerResize(viewer: any): void { @@ -888,12 +885,6 @@ class SeadragonCenterPanel extends CenterPanel { if (!this.isCreated) return; - if (this.currentBounds) { - this.fitToBounds( - typeof(this.currentBounds) == "string" ? Bounds.fromString(this.currentBounds) : this.currentBounds - ); - } - this.$title.ellipsisFill(this.extension.sanitize(this.title)); this.$spinner.css('top', (this.$content.height() / 2) - (this.$spinner.height() / 2));