-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b51910f
commit cf4a5af
Showing
18 changed files
with
363 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface Package<TOption> { | ||
getOption<K extends keyof TOption>(key: K): TOption[K]; | ||
setOptions(partialOptions: Partial<TOption>): this; | ||
setOption<K extends keyof TOption>(key: K, value: TOption[K]): this; | ||
clone(): ThisType<this>; | ||
isActive(): boolean; | ||
render(): this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Tour } from "./tour"; | ||
|
||
export type introBeforeChangeCallback = ( | ||
this: Tour, | ||
targetElement: HTMLElement, | ||
currentStep: number, | ||
direction: "backward" | "forward" | ||
) => Promise<boolean> | boolean; | ||
|
||
export type introChangeCallback = ( | ||
this: Tour, | ||
targetElement: HTMLElement | ||
) => void | Promise<void>; | ||
|
||
export type introAfterChangeCallback = ( | ||
this: Tour, | ||
targetElement: HTMLElement | ||
) => void | Promise<void>; | ||
|
||
export type introCompleteCallback = ( | ||
this: Tour, | ||
currentStep: number, | ||
reason: "skip" | "end" | "done" | ||
) => void | Promise<void>; | ||
|
||
export type introStartCallback = ( | ||
this: Tour, | ||
targetElement: HTMLElement | ||
) => void | Promise<void>; | ||
|
||
export type introExitCallback = (this: Tour) => void | Promise<void>; | ||
|
||
export type introSkipCallback = ( | ||
this: Tour, | ||
currentStep: number | ||
) => void | Promise<void>; | ||
|
||
export type introBeforeExitCallback = ( | ||
this: Tour, | ||
targetElement: HTMLElement | ||
) => boolean | Promise<boolean>; | ||
|
||
export type hintsAddedCallback = (this: Tour) => void | Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import addOverlayLayer from "../../core/addOverlayLayer"; | ||
import DOMEvent from "../../core/DOMEvent"; | ||
import { nextStep } from "../../core/steps"; | ||
import onKeyDown from "../../core/onKeyDown"; | ||
import onResize from "./onResize"; | ||
import fetchIntroSteps from "../../core/fetchIntroSteps"; | ||
import isFunction from "../../util/isFunction"; | ||
import { Tour } from "./tour"; | ||
|
||
/** | ||
* Initiate a new introduction/guide from an element in the page | ||
* | ||
* @api private | ||
*/ | ||
export default async function introForElement( | ||
tour: Tour, | ||
targetElm: HTMLElement | ||
): Promise<Boolean> { | ||
// don't start the tour if the instance is not active | ||
if (!tour.isActive()) return false; | ||
|
||
if (isFunction(tour._introStartCallback)) { | ||
await tour._introStartCallback.call(tour, targetElm); | ||
} | ||
|
||
//set it to the introJs object | ||
const steps = fetchIntroSteps(tour, targetElm); | ||
|
||
if (steps.length === 0) { | ||
return false; | ||
} | ||
|
||
tour.setSteps(steps); | ||
|
||
//add overlay layer to the page | ||
if (addOverlayLayer(tour, targetElm)) { | ||
//then, start the show | ||
await nextStep(tour); | ||
|
||
targetElm.addEventListener; | ||
if (tour.getOption("keyboardNavigation")) { | ||
DOMEvent.on(window, "keydown", onKeyDown, tour, true); | ||
} | ||
|
||
//for window resize | ||
DOMEvent.on(window, "resize", onResize, tour, true); | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import refresh from "../../core/refresh"; | ||
import { Tour } from "./tour"; | ||
|
||
export default function onResize(tour: Tour) { | ||
refresh(tour); | ||
} |
Oops, something went wrong.