Skip to content

Commit

Permalink
Render full image on active annotation or highlight (#2481)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoniePeters authored Nov 20, 2024
1 parent e41c0f7 commit 36ed3e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/portal/src/components/media/MediaImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
data() {
return {
fullImageRendered: false,
info: null,
olExtent: null,
olMap: null,
Expand Down Expand Up @@ -199,7 +200,11 @@
return new Feature(poly);
},
highlightAnnotation() {
async highlightAnnotation() {
if (!this.fullImageRendered) {
await this.renderFullImage();
}
this.initOlAnnotationLayer();
const layer = this.olMap.getLayers().item(1);
Expand Down Expand Up @@ -273,9 +278,10 @@
this.initOlMap(mapOptions);
this.olMap.getInteractions().forEach((interaction) => interaction.setActive(false));
// TODO: add other interactions: anno click, full-text search
this.olMap.on('click', this.renderFullImage);
this.olMap.getView().on('change:resolution', this.renderFullImageOnFirstZoomIn);
this.fullImageRendered = false;
},
renderFullImageOnFirstZoomIn(event) {
Expand All @@ -296,6 +302,8 @@
const url = this.$apis.record.mediaProxyUrl(this.url, this.itemId, { disposition: 'inline' });
const mapOptions = await this.initOlImageLayerStatic(url, this.width, this.height);
this.initMapWithFullImage(mapOptions);
this.fullImageRendered = true;
},
// IIIF Image API
Expand Down Expand Up @@ -340,6 +348,9 @@
if (this.source === 'IIIF') {
const mapOptions = this.initOlImageLayerIIIF();
this.initMapWithFullImage(mapOptions);
this.fullImageRendered = true;
} else if (this.annotation) {
this.renderFullImage();
} else {
this.renderThumbnail();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ describe('components/media/MediaImageViewer', () => {

describe('methods', () => {
describe('highlightAnnotation', () => {
describe('when the full image is not yet rendered', () => {
it('renders the full image', async() => {
const wrapper = factory({ propsData: { url, width, height } });

await wrapper.vm.highlightAnnotation();

expect(wrapper.vm.fullImageRendered).toBe(true);
});
});
it('initialises a vector layer for annotations', async() => {
const annotation = {
target: {
Expand Down

0 comments on commit 36ed3e9

Please sign in to comment.