Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ <h2>Highlight Feature</h2>
<button id="simple-highlight-btn">Simple Highlight</button>
<button id="transition-highlight-btn">Transition Highlight</button>
<button id="disallow-close">Disallow Close</button>
<button id="click-overlay-to-next">Click Overlay to Next</button>
<button id="dark-highlight-btn">Super Dark Highlight</button>
<button id="dim-highlight-btn">Super Dim Highlight</button>
<button id="scrollable-area-btn">Scrollable Area</button>
Expand Down Expand Up @@ -1099,6 +1100,16 @@ <h2>Usage and Demo</h2>
});
});

document.getElementById("click-overlay-to-next").addEventListener("click", () => {
const driverObj = driver({
animate: true,
overlayClickBehavior: 'nextStep',
steps: basicTourSteps,
});

driverObj.drive();
});

document.getElementById("destroy-btn").addEventListener("click", () => {
driver().destroy();
});
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Config = {
overlayOpacity?: number;
smoothScroll?: boolean;
allowClose?: boolean;
overlayClickBehavior?: 'close' | 'nextStep';
stagePadding?: number;
stageRadius?: number;

Expand Down Expand Up @@ -54,6 +55,7 @@ export function configure(config: Config = {}) {
currentConfig = {
animate: true,
allowClose: true,
overlayClickBehavior: 'close',
overlayOpacity: 0.7,
smoothScroll: false,
disableActiveInteraction: false,
Expand Down
15 changes: 14 additions & 1 deletion src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ export function driver(options: Config = {}) {
destroy();
}

function handleOverlayClick() {
const overlayClickBehavior = getConfig("overlayClickBehavior");

if (getConfig("allowClose") && overlayClickBehavior === "close") {
destroy();
return;
}

if (overlayClickBehavior === "nextStep") {
moveNext();
}
}

function moveNext() {
const activeIndex = getState("activeIndex");
const steps = getConfig("steps") || [];
Expand Down Expand Up @@ -129,7 +142,7 @@ export function driver(options: Config = {}) {

initEvents();

listen("overlayClick", handleClose);
listen("overlayClick", handleOverlayClick);
listen("escapePress", handleClose);
listen("arrowLeftPress", handleArrowLeft);
listen("arrowRightPress", handleArrowRight);
Expand Down