Skip to content

Commit

Permalink
feat(annotations): Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Mar 26, 2020
1 parent a1ba9ae commit 4b431b3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib/AnnotationControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export const CLASS_ANNOTATIONS_GROUP = 'bp-AnnotationControls-group';
export const CLASS_REGION_BUTTON = 'bp-AnnotationControls-regionBtn';
export const CLASS_BUTTON_ACTIVE = 'is-active';

export type RegionHandlerType = ({ isRegionActive, event }: { isRegionActive: boolean; event: MouseEvent }) => void;
export type Options = {
onRegionClick?: Function;
onRegionClick?: RegionHandlerType;
};

declare const __: (key: string) => string;
Expand All @@ -16,7 +17,7 @@ export default class AnnotationControls {
/** @property {Controls} - Controls object */
private controls: Controls;

/** @property {bool} - Region comment mode active state */
/** @property {boolean} - Region comment mode active state */
private isRegionActive = false;

/**
Expand All @@ -36,11 +37,11 @@ export default class AnnotationControls {
/**
* Region comment button click handler
*
* @param {Function} onRegionClick - region click handler in options
* @param {RegionHandlerType} onRegionClick - region click handler in options
* @param {MouseEvent} event - mouse event
* @return {void}
*/
private handleRegionClick = (onRegionClick: Function) => (event: MouseEvent): void => {
private handleRegionClick = (onRegionClick: RegionHandlerType) => (event: MouseEvent): void => {
const regionButtonElement = event.target as HTMLButtonElement;

this.isRegionActive = !this.isRegionActive;
Expand All @@ -56,7 +57,7 @@ export default class AnnotationControls {
/**
* Initialize the annotation controls with options.
*
* @param {Function} [options.onRegionClick] - Callback when region comment button is clicked
* @param {RegionHandlerType} [options.onRegionClick] - Callback when region comment button is clicked
* @return {void}
*/
public init({ onRegionClick = noop }: Options = {}): void {
Expand Down

0 comments on commit 4b431b3

Please sign in to comment.