Skip to content

Commit

Permalink
fix(discoverability): add getInitialAnnotationMode override (#1273)
Browse files Browse the repository at this point in the history
* fix(discoverability): add getInitialAnnotationMode override
  • Loading branch information
ChenCodes authored Oct 21, 2020
1 parent b42768a commit b64d8fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/viewers/image/ImageViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class ImageViewer extends ImageBaseViewer {
this.setScale(this.imageEl.offsetwidth, this.imageEl.offsetHeight);
}

// Annotation overrides
getInitialAnnotationMode() {
return this.options.enableAnnotationsImageDiscoverability ? AnnotationMode.REGION : AnnotationMode.NONE;
}

/**
* Gets the width & height after the transforms are applied.
* When an image is rotated, the width & height of an image, e.g. offsetWidth & offsetHeight,
Expand Down
15 changes: 15 additions & 0 deletions src/lib/viewers/image/__tests__/ImageViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ describe('lib/viewers/image/ImageViewer', () => {
});
});

describe('getInitialAnnotationMode()', () => {
test.each`
mode | enableAnnotationsImageDiscoverability
${AnnotationMode.REGION} | ${true}
${AnnotationMode.NONE} | ${false}
`(
'should return $mode if enableAnnotationsImageDiscoverability is $enableAnnotationsImageDiscoverability',
({ enableAnnotationsImageDiscoverability, mode }) => {
image.options.enableAnnotationsImageDiscoverability = enableAnnotationsImageDiscoverability;

expect(image.getInitialAnnotationMode()).toBe(mode);
},
);
});

describe('getTransformWidthAndHeight', () => {
test('should return the same width & height if the image is not rotated', () => {
const width = 100;
Expand Down

0 comments on commit b64d8fc

Please sign in to comment.