-
Notifications
You must be signed in to change notification settings - Fork 116
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
New: drawing dialog #364
New: drawing dialog #364
Changes from 7 commits
2a30760
59f68a6
cf356cb
c18c295
2035dfa
c89cab1
004fed9
99ea86f
14cd2f8
1184742
7967ab4
07312e7
6f34771
441203f
88aaa45
16f854f
6695924
c58e8a0
14ddbaf
bdd4270
e9a4f76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -439,7 +439,7 @@ export function validateThreadParams(thread) { | |
} | ||
|
||
/** | ||
* Returns a function that passes a callback a location when given an event | ||
* Returns a function that passes a callback a location when given an event on the document text layer | ||
* | ||
* @param {Function} locationFunction - The function to get a location from an event | ||
* @param {Function} callback - Callback to be called upon receiving an event | ||
|
@@ -448,7 +448,8 @@ export function validateThreadParams(thread) { | |
export function eventToLocationHandler(locationFunction, callback) { | ||
return (event) => { | ||
const evt = event || window.event; | ||
if (!evt) { | ||
// Do nothing when the target isn't the text layer in case the text layer receives event precedence over buttons | ||
if (!evt || (event.target && event.target.className !== 'textLayer')) { | ||
return; | ||
} | ||
|
||
|
@@ -459,6 +460,20 @@ export function eventToLocationHandler(locationFunction, callback) { | |
}; | ||
} | ||
|
||
/** | ||
* Call preventDefault and stopPropagation on an event | ||
* | ||
* @param {event} event - Event object to stop event bubbling | ||
* @return {void} | ||
*/ | ||
export function prevDefAndStopProp(event) { | ||
if (!event) { | ||
return; | ||
} | ||
|
||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline after the block! |
||
* Create a JSON object containing x/y coordinates and optionally dimensional information | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -454,6 +454,10 @@ class DocAnnotator extends Annotator { | |
bindDOMListeners() { | ||
super.bindDOMListeners(); | ||
|
||
if (!this.permissions.canAnnotate) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment on #362 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove |
||
return; | ||
} | ||
|
||
this.annotatedElement.addEventListener('mouseup', this.highlightMouseupHandler); | ||
|
||
if (this.hasTouch && this.isMobile) { | ||
|
@@ -485,6 +489,12 @@ class DocAnnotator extends Annotator { | |
this.highlightThrottleHandle = null; | ||
} | ||
|
||
if (!this.permissions.canAnnotate) { | ||
return; | ||
} | ||
|
||
Object.values(this.modeControllers).forEach((controller) => controller.cleanSelector()); | ||
|
||
if (this.hasTouch && this.isMobile) { | ||
document.removeEventListener('selectionchange', this.onSelectionChange); | ||
this.annotatedElement.removeEventListener('touchstart', this.drawingSelectionHandler); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
exitInactiveAnnotationModes
?