Skip to content
Snippets Groups Projects
Verified Commit 26448c93 authored by Loïs Poujade's avatar Loïs Poujade
Browse files

Merge branch 'annotation-on-video' into 3-upstream-01022023

parents 347dde1f bd345caa
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ describe('CanvasAnnotationDisplay', () => { ...@@ -32,7 +32,7 @@ describe('CanvasAnnotationDisplay', () => {
subject.fragmentContext = jest.fn(); subject.fragmentContext = jest.fn();
subject.toContext(context); subject.toContext(context);
expect(subject.svgContext).toHaveBeenCalled(); 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', () => { it('selects fragmentSelector if present and if no svg is present', () => {
const context = { const context = {
...@@ -44,7 +44,7 @@ describe('CanvasAnnotationDisplay', () => { ...@@ -44,7 +44,7 @@ describe('CanvasAnnotationDisplay', () => {
subject.svgContext = jest.fn(); subject.svgContext = jest.fn();
subject.fragmentContext = jest.fn(); subject.fragmentContext = jest.fn();
subject.toContext(context); subject.toContext(context);
expect(subject.svgContext).not.toHaveBeenCalled(); // expect(subject.svgContext).not.toHaveBeenCalled();
expect(subject.fragmentContext).toHaveBeenCalled(); expect(subject.fragmentContext).toHaveBeenCalled();
}); });
it('ignores annotations without selectors', () => { it('ignores annotations without selectors', () => {
......
...@@ -417,13 +417,14 @@ export class AnnotationsOverlayVideo extends Component { ...@@ -417,13 +417,14 @@ export class AnnotationsOverlayVideo extends Component {
return { height: 0, width: 0 }; return { height: 0, width: 0 };
} }
/** @private */ /** @private - Returns the first Image body */
getResourceImage(resource) { getResourceImage(resource) {
let imageSource; const imageSource = [];
if (resource.body && resource.body.length > 0 && resource.body[0].type === 'Image') {
const src = resource.body[0].id; for (const body of resource.body.filter(b => b.type === 'Image')) {
const src = body.id;
if (this.imagesReady[src]) { if (this.imagesReady[src]) {
imageSource = this.imagesReady[src]; imageSource.push(this.imagesReady[src]);
} else if (!this.imagesLoading.includes(src)) { } else if (!this.imagesLoading.includes(src)) {
this.imagesLoading.push(src); this.imagesLoading.push(src);
const img = new Image(); const img = new Image();
...@@ -433,7 +434,8 @@ export class AnnotationsOverlayVideo extends Component { ...@@ -433,7 +434,8 @@ export class AnnotationsOverlayVideo extends Component {
img.src = src; img.src = src;
} }
} }
return imageSource;
return imageSource[0];
} }
/** @private */ /** @private */
......
...@@ -22,7 +22,8 @@ export default class CanvasAnnotationDisplay { ...@@ -22,7 +22,8 @@ export default class CanvasAnnotationDisplay {
this.context = context; this.context = context;
if (this.resource.svgSelector) { if (this.resource.svgSelector) {
this.svgContext(); this.svgContext();
} else if (this.resource.fragmentSelector) { }
if (this.resource.fragmentSelector) {
this.fragmentContext(); this.fragmentContext();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment