Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Moved guards so drawing works when highlights disabled #409

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/lib/annotations/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,19 +530,27 @@ class DocAnnotator extends Annotator {
this.annotatedElement.addEventListener('mouseup', this.highlightMouseupHandler);

// Prevent all forms of highlight annotations if annotating (or plain AND comment highlights) is disabled
if (!this.permissions.canAnnotate || (!this.plainHighlightEnabled && !this.commentHighlightEnabled)) {
if (!this.permissions.canAnnotate) {
return;
}

if (this.hasTouch && this.isMobile) {
document.addEventListener('selectionchange', this.onSelectionChange);
this.annotatedElement.addEventListener('touchstart', this.drawingSelectionHandler);

// Highlight listeners
if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
document.addEventListener('selectionchange', this.onSelectionChange);
}
} else {
this.annotatedElement.addEventListener('click', this.drawingSelectionHandler);
this.annotatedElement.addEventListener('dblclick', this.highlightMouseupHandler);
this.annotatedElement.addEventListener('mousedown', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('contextmenu', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('mousemove', this.getHighlightMouseMoveHandler());

// Highlight listeners
if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
this.annotatedElement.addEventListener('dblclick', this.highlightMouseupHandler);
this.annotatedElement.addEventListener('mousedown', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('contextmenu', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('mousemove', this.getHighlightMouseMoveHandler());
}
}
}

Expand Down