Skip to content

Commit

Permalink
Chore: Only remove annotation listeners if enabled on viewer (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Aug 10, 2017
1 parent b63eab2 commit 9b97fd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ class BaseViewer extends EventEmitter {
* @return {boolean} Whether or not viewer is annotatable
*/
isAnnotatable(type) {
if (!this.annotatorConf) {
return false;
}

const { TYPE: annotationTypes } = this.annotatorConf;
if (type && annotationTypes) {
if (!annotationTypes.some((annotationType) => type === annotationType)) {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ describe('lib/viewers/BaseViewer', () => {
sandbox.stub(base, 'areAnnotationsEnabled').returns(true);
});

it('should return false if annotations are not allowed on the current viewer', () => {
base.annotatorConf = undefined;
expect(base.isAnnotatable('point')).to.equal(false);
})

it('should return true if the type is supported by the viewer', () => {
expect(base.isAnnotatable('point')).to.equal(true);
});
Expand Down

0 comments on commit 9b97fd7

Please sign in to comment.