Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Feb 15, 2017
2 parents 09b59b0 + 792196f commit d8996cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 44 deletions.
7 changes: 5 additions & 2 deletions src/extensions/uv-seadragon-extension/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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{
Expand Down
75 changes: 33 additions & 42 deletions src/modules/uv-seadragoncenterpanel-module/SeadragonCenterPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {

Expand Down Expand Up @@ -568,10 +538,8 @@ class SeadragonCenterPanel extends CenterPanel {
}

this.setNavigatorVisible();

this.isFirstLoad = false;

this.overlaySearchResults();
this.updateBounds();

let searchResultRect: SearchResultRect = this.getInitialSearchResultRect();

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit d8996cc

Please sign in to comment.