Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@google/model-viewer": "^4.0.0",
"@iiif/base-component": "2.0.1",
"@iiif/iiif-av-component": "1.2.4",
"@iiif/manifold": "^2.1.1",
"@iiif/manifold": "^2.1.3",
"@iiif/presentation-3": "^1.0.5",
"@iiif/vocabulary": "^1.0.29",
"@openseadragon-imaging/openseadragon-viewerinputhook": "^2.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
let indices: number[] = [];

// if it's a continuous manifest, get all resources.
if (sequence.getViewingHint() === ViewingHint.CONTINUOUS) {
if (this.helper.isContinuous()) {
// get all canvases to be displayed inline
indices = canvases.map((_canvas: Canvas, index: number) => {
return index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,13 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
maxZoomPixelRatio: this.config.options.maxZoomPixelRatio || 2,
controlsFadeDelay: this.config.options.controlsFadeDelay || 250,
controlsFadeLength: this.getControlsFadeLength(),
navigatorPosition:
this.config.options.navigatorPosition || "BOTTOM_RIGHT",
navigatorPosition: this.extension.helper.isContinuous()
? "BOTTOM_LEFT"
: this.config.options.navigatorPosition || "BOTTOM_RIGHT",
navigatorHeight: "100px",
navigatorWidth: "100px",
navigatorMaintainSizeRatio: false,
navigatorAutoResize: false,
animationTime: this.config.options.animationTime || 1.2,
visibilityRatio: this.config.options.visibilityRatio || 0.5,
constrainDuringPan: Bools.getBool(
Expand Down Expand Up @@ -912,6 +915,13 @@ export class OpenSeadragonCenterPanel extends CenterPanel<

this.setNavigatorVisible();

// resize navigator for continuous manifests
if (this.extension.helper.isContinuous()) {
setTimeout(() => {
this.resizeNavigatorForContinuous();
}, 200);
}

this.overlayAnnotations();

this.updateBounds();
Expand All @@ -925,6 +935,58 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
this.isFirstLoad = false;
}

private resizeNavigatorForContinuous(): void {
if (!this.viewer || !this.viewer.navigator) return;

const homeBounds = this.viewer.world.getHomeBounds();
const contentAspectRatio = homeBounds.width / homeBounds.height;

const viewportWidth = this.$viewer.width();
const viewportHeight = this.$viewer.height();
const maxNavigatorWidth = 100;
const maxNavigatorHeight = 100;
const minVerticalNavigatorWidth = 60;
const minHorizontalNavigatorHeight = 40;

let navigatorWidth: number;
let navigatorHeight: number;

if (this.extension.helper.isVerticallyAligned()) {
navigatorHeight = viewportHeight - this.$zoomInButton.height() - 4;
navigatorWidth = navigatorHeight * contentAspectRatio;

// Enforce max width
if (navigatorWidth > maxNavigatorWidth) {
navigatorWidth = maxNavigatorWidth;
}

// Enforce min width
if (navigatorWidth < minVerticalNavigatorWidth) {
navigatorWidth = minVerticalNavigatorWidth;
}
} else {
navigatorWidth = viewportWidth;
navigatorHeight = navigatorWidth / contentAspectRatio;

// Enforce max height
if (navigatorHeight > maxNavigatorHeight) {
navigatorHeight = maxNavigatorHeight;
}

// Enforce min height
if (navigatorHeight < minHorizontalNavigatorHeight) {
navigatorHeight = minHorizontalNavigatorHeight;
}
}

const navigatorElement = this.viewer.navigator.element;
navigatorElement.style.width = `${navigatorWidth}px`;
navigatorElement.style.height = `${navigatorHeight}px`;

this.viewer.navigator.viewport.fitBounds(homeBounds, true);
this.viewer.navigator.updateSize();
}

zoomToInitialAnnotation(): void {
const annotationRect: AnnotationRect | null =
this.getInitialAnnotationRect();
Expand Down Expand Up @@ -1506,20 +1568,27 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
);
break;
}
}

// stretch navigator, allowing time for OSD to resize
setTimeout(() => {
// resize navigator for continuous manifests
if (this.extension.helper.isContinuous()) {
if (this.extension.helper.isHorizontallyAligned()) {
const width: number =
this.$viewer.width() - this.$viewer.rightMargin();
this.$navigator.width(width);
} else {
this.$navigator.height(this.$viewer.height());
}
setTimeout(() => {
this.resizeNavigatorForContinuous();
}, 200);
}
}, 100);
}

// stretch navigator, allowing time for OSD to resize
// setTimeout(() => {
// if (this.extension.helper.isContinuous()) {
// if (this.extension.helper.isHorizontallyAligned()) {
// const width: number =
// this.$viewer.width() - this.$viewer.rightMargin();
// this.$navigator.width(width);
// } else {
// this.$navigator.height(this.$viewer.height());
// }
// }
// }, 100);
Comment on lines +1580 to +1591
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented-out code actually needed for future reference, or is this an abandoned experiment?

}

setFocus(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
Manifest,
Range,
} from "manifesto.js";
import { ViewingHint } from "@iiif/vocabulary/dist-commonjs/";
// import { ViewingHint } from "@iiif/vocabulary/dist-commonjs/";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this now?

import * as KeyCodes from "../../KeyCodes";
import {
Bools,
Expand Down Expand Up @@ -1091,12 +1091,7 @@ export class BaseExtension<T extends BaseConfig> implements IExtension {
if (this.helper.hasParentCollection()) {
return true;
} else if (this.helper.isMultiCanvas()) {
const viewingHint: ViewingHint | null = this.helper.getViewingHint();

if (
!viewingHint ||
(viewingHint && viewingHint !== ViewingHint.CONTINUOUS)
) {
if (!this.helper.isContinuous()) {
return true;
}
}
Expand Down