diff --git a/__tests__/src/lib/CanvasAnnotationDisplay.test.js b/__tests__/src/lib/CanvasAnnotationDisplay.test.js index 721ef34a6f9440ba37d120857eae9ad10098e17a..3174e07385d18721014d659e4bac577808b90983 100644 --- a/__tests__/src/lib/CanvasAnnotationDisplay.test.js +++ b/__tests__/src/lib/CanvasAnnotationDisplay.test.js @@ -32,7 +32,7 @@ describe('CanvasAnnotationDisplay', () => { subject.fragmentContext = jest.fn(); subject.toContext(context); expect(subject.svgContext).toHaveBeenCalled(); - expect(subject.fragmentContext).not.toHaveBeenCalled(); + // expect(subject.fragmentContext).not.toHaveBeenCalled(); }); it('selects fragmentSelector if present and if no svg is present', () => { const context = { @@ -44,7 +44,7 @@ describe('CanvasAnnotationDisplay', () => { subject.svgContext = jest.fn(); subject.fragmentContext = jest.fn(); subject.toContext(context); - expect(subject.svgContext).not.toHaveBeenCalled(); + // expect(subject.svgContext).not.toHaveBeenCalled(); expect(subject.fragmentContext).toHaveBeenCalled(); }); it('ignores annotations without selectors', () => { diff --git a/src/components/AnnotationsOverlayVideo.js b/src/components/AnnotationsOverlayVideo.js index bc4562cfcf609a475fa6823556286994f6edb571..95c63bd0fa92c1eb26d39518f72a9a99b52e9781 100755 --- a/src/components/AnnotationsOverlayVideo.js +++ b/src/components/AnnotationsOverlayVideo.js @@ -417,13 +417,14 @@ export class AnnotationsOverlayVideo extends Component { return { height: 0, width: 0 }; } - /** @private */ + /** @private - Returns the first Image body */ getResourceImage(resource) { - let imageSource; - if (resource.body && resource.body.length > 0 && resource.body[0].type === 'Image') { - const src = resource.body[0].id; + const imageSource = []; + + for (const body of resource.body.filter(b => b.type === 'Image')) { + const src = body.id; if (this.imagesReady[src]) { - imageSource = this.imagesReady[src]; + imageSource.push(this.imagesReady[src]); } else if (!this.imagesLoading.includes(src)) { this.imagesLoading.push(src); const img = new Image(); @@ -433,7 +434,8 @@ export class AnnotationsOverlayVideo extends Component { img.src = src; } } - return imageSource; + + return imageSource[0]; } /** @private */ diff --git a/src/lib/CanvasAnnotationDisplay.js b/src/lib/CanvasAnnotationDisplay.js index 437f9cfe58baab8fbc7cc57274291fc08c4c9eb6..673e492f44dee4b8aa874321aca1c05d8d67c756 100644 --- a/src/lib/CanvasAnnotationDisplay.js +++ b/src/lib/CanvasAnnotationDisplay.js @@ -22,7 +22,8 @@ export default class CanvasAnnotationDisplay { this.context = context; if (this.resource.svgSelector) { this.svgContext(); - } else if (this.resource.fragmentSelector) { + } + if (this.resource.fragmentSelector) { this.fragmentContext(); } }