Skip to content

Commit

Permalink
make onHighlightHoverStateChange callback optional
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWang15 committed Sep 30, 2021
1 parent 41e9e4e commit d9a1002
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lib/classes/EventHandler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Context from "./Context";

interface EventHandler {
onHighlightClick: (context: Context, element: HTMLElement) => void;
onHighlightHoverStateChange: (
onHighlightClick?: (context: Context, element: HTMLElement) => void;
onHighlightHoverStateChange?: (
context: Context,
element: HTMLElement,
hovering: boolean
Expand Down
12 changes: 7 additions & 5 deletions src/lib/classes/Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,13 @@ class Marker {

private highlightHovering(highlightId: string, hovering: boolean) {
for (let element of Marker.resolveHighlightElements(highlightId)) {
this.eventHandler.onHighlightHoverStateChange(
this.buildContext(highlightId),
element as any,
hovering
);
if (this.eventHandler.onHighlightHoverStateChange) {
this.eventHandler.onHighlightHoverStateChange(
this.buildContext(highlightId),
element as any,
hovering
);
}
}
}

Expand Down

0 comments on commit d9a1002

Please sign in to comment.