Skip to content

Commit

Permalink
Merge pull request UniversalViewer#920 from UniversalViewer/feature/b…
Browse files Browse the repository at this point in the history
…l-may-23-2

Added support for range-based time changes
  • Loading branch information
stephenwf authored Jun 20, 2023
2 parents 5f212a9 + 79ab4fc commit fd33d27
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
14 changes: 7 additions & 7 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 @@ -87,7 +87,7 @@
"@edsilv/utils": "^1.0.2",
"@google/model-viewer": "^1.9.2",
"@iiif/base-component": "2.0.1",
"@iiif/iiif-av-component": "^1.2.1",
"@iiif/iiif-av-component": "1.2.3",
"@iiif/iiif-gallery-component": "^1.1.21",
"@iiif/iiif-metadata-component": "^1.1.19",
"@iiif/iiif-tree-component": "^2.0.3",
Expand Down
1 change: 1 addition & 0 deletions src/content-handlers/iiif/IIIFEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class IIIFEvents {
static COLLECTION_INDEX_CHANGE: string = "collectionIndexChange";
static CREATE: string = "create";
static CURRENT_TIME_CHANGE: string = "currentTimeChanged";
static RANGE_TIME_CHANGE: string = "rangeTimeChanged";
static DOWN_ARROW: string = "downArrow";
static DOWNLOAD: string = "download";
static END: string = "end";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ export class AVCenterPanel extends CenterPanel {
}
);

this.extensionHost.subscribe(
IIIFEvents.RANGE_TIME_CHANGE,
({ time, rangeId }: { time: number; rangeId: string }) => {
this._whenMediaReady(() => {
if (this.avcomponent) {
this.avcomponent.setCurrentRangeTime(time, rangeId, true);
}
});
}
);

this.extensionHost.subscribe(
IIIFEvents.RANGE_CHANGE,
(range: Range | null) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ export class MoreInfoRightPanel extends RightPanel {
"rid",
href
);
// Time change.
const time: string | null = Urls.getHashParameterFromString(
"t",
href
);

if (rangeId) {
if (rangeId && time === null) {
const range: Range | null = this.extension.helper.getRangeById(
rangeId
);
Expand All @@ -59,16 +64,21 @@ export class MoreInfoRightPanel extends RightPanel {
}
}

// Time change.
const time: string | null = Urls.getHashParameterFromString(
"t",
href
);

if (time !== null) {
const timeAsNumber = Number(time);
if (!Number.isNaN(timeAsNumber)) {
this.extensionHost.publish(IIIFEvents.CURRENT_TIME_CHANGE, timeAsNumber);

if (rangeId) {
// We want to make the time change RELATIVE to the start of the range.
const range: Range | null = this.extension.helper.getRangeById(
rangeId
);
if (range) {
this.extensionHost.publish(IIIFEvents.RANGE_TIME_CHANGE, { rangeId: range.id, time: timeAsNumber });
}
} else {
this.extensionHost.publish(IIIFEvents.CURRENT_TIME_CHANGE, timeAsNumber);
}
}
}
},
Expand Down

0 comments on commit fd33d27

Please sign in to comment.