Skip to content
Open
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
19 changes: 15 additions & 4 deletions src/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
export class Manifest extends IIIFResource {
public index: number = 0;
private _allRanges: Range[] | null = null;
public items: Sequence[] = [];
public items: (Sequence | Range)[] = [];
private _topRanges: Range[] = [];

constructor(jsonld?: any, options?: IManifestoOptions) {
Expand Down Expand Up @@ -238,8 +238,15 @@ export class Manifest extends IIIFResource {
return null;
}

getSequences(): Sequence[] {
if (this.items.length) {
getSequences(): (Sequence | Range)[] {
let v3SeqRanges: Range[] = [];
if (this.getTopRanges().length > 0) {
v3SeqRanges = this.getTopRanges().filter(
r => r.getBehavior() == "sequence"
);
}

if (v3SeqRanges.length === 0 && this.items.length) {
return this.items;
}

Expand All @@ -258,10 +265,14 @@ export class Manifest extends IIIFResource {
this.items.push(sequence);
}

if (v3SeqRanges.length > 0) {
this.items.concat(v3SeqRanges);
}

return this.items;
}

getSequenceByIndex(sequenceIndex: number): Sequence {
getSequenceByIndex(sequenceIndex: number): Sequence | Range {
return this.getSequences()[sequenceIndex];
}

Expand Down
55 changes: 54 additions & 1 deletion test/fixtures/pres3.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,59 @@
]
}
]
},
{
"id": "http://example.org/iiif/book1/canvas/1",
"type": "Canvas",
"label": {
"@none": [
"p. 1"
]
},
"height": 1000,
"width": 750,
"duration": 180.0,
"items": [
{
"id": "http://example.org/iiif/book1/canvas/1/annotationpage/0",
"type": "AnnotationPage",
"items": [
{
"id": "http://example.org/iiif/book1/canvas/1/annotation/0",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "http://example.org/iiif/book1/canvas/1/images/page1.jpg",
"type": "Image",
"format": "image/jpeg",
"label": {
"@none": [
"Page 1"
]
}
},
"target": "http://example.org/iiif/book1/canvas/1"
}
]
}
]
}
],
"structures": [
{
"id": "http://foo.test/1/range/root",
"type": "Range",
"behavior": "sequence",
"items": [
{
"type": "SpecificResource",
"source": "http://example.org/iiif/book1/canvas/0",
"selector": {
"type": "FragmentSelector",
"value": "xywh=0,0,750,300"
}
}
]
}
]
}
}