Skip to content

Commit 09009c2

Browse files
authored
Issue 1503, fix continuous behavior (#1519)
1 parent 57fd626 commit 09009c2

File tree

5 files changed

+76
-26
lines changed

5 files changed

+76
-26
lines changed

β€Žpackage-lock.jsonβ€Ž

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"@google/model-viewer": "^4.0.0",
100100
"@iiif/base-component": "2.0.1",
101101
"@iiif/iiif-av-component": "1.2.4",
102-
"@iiif/manifold": "^2.1.1",
102+
"@iiif/manifold": "^2.1.3",
103103
"@iiif/presentation-3": "^1.0.5",
104104
"@iiif/vocabulary": "^1.0.31",
105105
"@openseadragon-imaging/openseadragon-viewerinputhook": "^2.2.1",

β€Žsrc/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
15881588
let indices: number[] = [];
15891589

15901590
// if it's a continuous manifest, get all resources.
1591-
if (sequence.getViewingHint() === ViewingHint.CONTINUOUS) {
1591+
if (this.helper.isContinuous()) {
15921592
// get all canvases to be displayed inline
15931593
indices = canvases.map((_canvas: Canvas, index: number) => {
15941594
return index;

β€Žsrc/content-handlers/iiif/modules/uv-openseadragoncenterpanel-module/OpenSeadragonCenterPanel.tsβ€Ž

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,13 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
251251
maxZoomPixelRatio: this.config.options.maxZoomPixelRatio || 2,
252252
controlsFadeDelay: this.config.options.controlsFadeDelay || 250,
253253
controlsFadeLength: this.getControlsFadeLength(),
254-
navigatorPosition:
255-
this.config.options.navigatorPosition || "BOTTOM_RIGHT",
254+
navigatorPosition: this.extension.helper.isContinuous()
255+
? "BOTTOM_LEFT"
256+
: this.config.options.navigatorPosition || "BOTTOM_RIGHT",
256257
navigatorHeight: "100px",
257258
navigatorWidth: "100px",
259+
navigatorMaintainSizeRatio: false,
260+
navigatorAutoResize: false,
258261
animationTime: this.config.options.animationTime || 1.2,
259262
visibilityRatio: this.config.options.visibilityRatio || 0.5,
260263
constrainDuringPan: Bools.getBool(
@@ -914,6 +917,13 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
914917

915918
this.setNavigatorVisible();
916919

920+
// resize navigator for continuous manifests
921+
if (this.extension.helper.isContinuous()) {
922+
setTimeout(() => {
923+
this.resizeNavigatorForContinuous();
924+
}, 200);
925+
}
926+
917927
this.overlayAnnotations();
918928

919929
this.updateBounds();
@@ -927,6 +937,58 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
927937
this.isFirstLoad = false;
928938
}
929939

940+
private resizeNavigatorForContinuous(): void {
941+
if (!this.viewer || !this.viewer.navigator) return;
942+
943+
const homeBounds = this.viewer.world.getHomeBounds();
944+
const contentAspectRatio = homeBounds.width / homeBounds.height;
945+
946+
const viewportWidth = this.$viewer.width();
947+
const viewportHeight = this.$viewer.height();
948+
const maxNavigatorWidth = 100;
949+
const maxNavigatorHeight = 100;
950+
const minVerticalNavigatorWidth = 60;
951+
const minHorizontalNavigatorHeight = 40;
952+
953+
let navigatorWidth: number;
954+
let navigatorHeight: number;
955+
956+
if (this.extension.helper.isVerticallyAligned()) {
957+
navigatorHeight = viewportHeight - this.$zoomInButton.height() - 4;
958+
navigatorWidth = navigatorHeight * contentAspectRatio;
959+
960+
// Enforce max width
961+
if (navigatorWidth > maxNavigatorWidth) {
962+
navigatorWidth = maxNavigatorWidth;
963+
}
964+
965+
// Enforce min width
966+
if (navigatorWidth < minVerticalNavigatorWidth) {
967+
navigatorWidth = minVerticalNavigatorWidth;
968+
}
969+
} else {
970+
navigatorWidth = viewportWidth;
971+
navigatorHeight = navigatorWidth / contentAspectRatio;
972+
973+
// Enforce max height
974+
if (navigatorHeight > maxNavigatorHeight) {
975+
navigatorHeight = maxNavigatorHeight;
976+
}
977+
978+
// Enforce min height
979+
if (navigatorHeight < minHorizontalNavigatorHeight) {
980+
navigatorHeight = minHorizontalNavigatorHeight;
981+
}
982+
}
983+
984+
const navigatorElement = this.viewer.navigator.element;
985+
navigatorElement.style.width = `${navigatorWidth}px`;
986+
navigatorElement.style.height = `${navigatorHeight}px`;
987+
988+
this.viewer.navigator.viewport.fitBounds(homeBounds, true);
989+
this.viewer.navigator.updateSize();
990+
}
991+
930992
zoomToInitialAnnotation(): void {
931993
const annotationRect: AnnotationRect | null =
932994
this.getInitialAnnotationRect();
@@ -1508,20 +1570,14 @@ export class OpenSeadragonCenterPanel extends CenterPanel<
15081570
);
15091571
break;
15101572
}
1511-
}
15121573

1513-
// stretch navigator, allowing time for OSD to resize
1514-
setTimeout(() => {
1574+
// resize navigator for continuous manifests
15151575
if (this.extension.helper.isContinuous()) {
1516-
if (this.extension.helper.isHorizontallyAligned()) {
1517-
const width: number =
1518-
this.$viewer.width() - this.$viewer.rightMargin();
1519-
this.$navigator.width(width);
1520-
} else {
1521-
this.$navigator.height(this.$viewer.height());
1522-
}
1576+
setTimeout(() => {
1577+
this.resizeNavigatorForContinuous();
1578+
}, 200);
15231579
}
1524-
}, 100);
1580+
}
15251581
}
15261582

15271583
setFocus(): void {

β€Žsrc/content-handlers/iiif/modules/uv-shared-module/BaseExtension.tsβ€Ž

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
Manifest,
3232
Range,
3333
} from "manifesto.js";
34-
import { ViewingHint } from "@iiif/vocabulary/dist-commonjs/";
3534
import * as KeyCodes from "../../KeyCodes";
3635
import {
3736
Bools,
@@ -1091,12 +1090,7 @@ export class BaseExtension<T extends BaseConfig> implements IExtension {
10911090
if (this.helper.hasParentCollection()) {
10921091
return true;
10931092
} else if (this.helper.isMultiCanvas()) {
1094-
const viewingHint: ViewingHint | null = this.helper.getViewingHint();
1095-
1096-
if (
1097-
!viewingHint ||
1098-
(viewingHint && viewingHint !== ViewingHint.CONTINUOUS)
1099-
) {
1093+
if (!this.helper.isContinuous()) {
11001094
return true;
11011095
}
11021096
}

0 commit comments

Comments
Β (0)