Skip to content

Commit

Permalink
implement callback check function for onClick event callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
leopoldjoy committed Nov 8, 2018
1 parent 9a1a5f5 commit f756e17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default compose(
onMouseDown: T.func,
onMouseMove: T.func,
onClick: T.func,
// This function is run before the onClick callback is executed (onClick
// is only called if onClickCheckFunc resolve to true or doesn't exist)
onClickCheckFunc: T.func,
// For Polygon Selector
onSelectionComplete: T.func,
onSelectionClear: T.func,
Expand Down Expand Up @@ -153,7 +156,14 @@ export default compose(
onMouseUp = (e) => this.callSelectorMethod('onMouseUp', e)
onMouseDown = (e) => this.callSelectorMethod('onMouseDown', e)
onMouseMove = (e) => this.callSelectorMethod('onMouseMove', e)
onClick = (e) => this.callSelectorMethod('onClick', e)
onClick = (e) => {
const { onClickCheckFunc } = this.props;

if (!onClickCheckFunc || onClickCheckFunc()) {
return this.callSelectorMethod('onClick', e)
}
return;
}
onSelectionComplete = () => this.callSelectorMethod('onSelectionComplete')
onSelectionClear = () => this.callSelectorMethod('onSelectionClear')
onSelectionUndo = () => this.callSelectorMethod('onSelectionUndo')
Expand Down
2 changes: 1 addition & 1 deletion src/hocs/PolygonSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const methods = {
}
},

onMouseUp (annotation, e) {
onClick (annotation, e) {
const coordOfClick = getCoordPercentage(e)

return {
Expand Down

0 comments on commit f756e17

Please sign in to comment.