Skip to content

Commit

Permalink
feat: add onStart option that is called when boarding.start is called
Browse files Browse the repository at this point in the history
  • Loading branch information
josias-r committed Jan 11, 2023
1 parent 05821bf commit 9f18187
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ <h4>Boarding Definition</h4>
onHighlighted: (Element) {}, // Called when element is fully highlighted
onDeselected: (Element) {}, // Called when element has been deselected
onReset: (Element) {}, // Called when overlay is about to be cleared
onStart: (Element) {}, // Called when `boarding.start()` was called
onNext: (Element) =&gt; {}, // Called when moving to next step on any step
onPrevious: (Element) =&gt; {}, // Called when moving to next step on any step
strictClickHandling: "block-all", // Can also be `true` or if not wanted at all, `false`. Either block ALL pointer events, or isolate pointer-events to only allow on the highlighted element (`true`). Popover and overlay pointer-events are of course always allowed to be clicked
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ const boarding = new Boarding({
onHighlighted: (HighlightElement) => {}, // Called when element is fully highlighted
onDeselected: (HighlightElement) => {}, // Called when element has been deselected
onReset: (HighlightElement) => {}, // Called when overlay is about to be cleared
onStart: (HighlightElement) => {}, // Called when `boarding.start()` was called
onNext: (HighlightElement) => {}, // Called when moving to next step on any step
onPrevious: (HighlightElement) => {}, // Called when moving to previous step on any step
strictClickHandling: true, // Can also be `"block-all"` or if not wanted at all, `false`. Either block ALL pointer events, or isolate pointer-events to only allow on the highlighted element (`true`). Popover and overlay pointer-events are of course always allowed to be clicked
Expand Down
8 changes: 7 additions & 1 deletion src/lib/boarding-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { HighlightElementHybridOptions } from "./core/highlight-element";
import HighlightElement, {
HighlightElementHybridOptions,
} from "./core/highlight-element";
import { OverlayTopLevelOptions } from "./core/overlay";
import {
PopoverHybridOptions,
Expand Down Expand Up @@ -62,6 +64,10 @@ export interface BoardingOptions
* className for the boarding popovers
*/
className?: string;
/**
* Simple event that triggers for boarding.start()
*/
onStart?: (element: HighlightElement) => void;
}

export interface BoardingStepDefinition extends HighlightElementHybridOptions {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/boarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ class Boarding {
}

this.currentStep = index;

this.options.onStart?.(element);
this.activateBoarding(element);
}

Expand Down

0 comments on commit 9f18187

Please sign in to comment.