Fixes #383 - adds support for disableActiveInteraction option
Browse files- index.html +8 -0
- src/config.ts +3 -0
- src/driver.css +8 -2
- src/highlight.ts +7 -2
- src/utils.ts +3 -1
index.html
CHANGED
@@ -386,6 +386,13 @@ npm install driver.js</pre
|
|
386 |
description: "You can now have popovers without elements as well",
|
387 |
},
|
388 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
{
|
390 |
element: "#scrollable-area",
|
391 |
popover: {
|
@@ -457,6 +464,7 @@ npm install driver.js</pre
|
|
457 |
const driverObj = driver({
|
458 |
animate: true,
|
459 |
steps: basicTourSteps,
|
|
|
460 |
showProgress: true,
|
461 |
progressText: "{{current}} of {{total}} done",
|
462 |
onPopoverRender: (popover) => {
|
|
|
386 |
description: "You can now have popovers without elements as well",
|
387 |
},
|
388 |
},
|
389 |
+
{
|
390 |
+
element: '.buttons',
|
391 |
+
popover: {
|
392 |
+
title: "Buttons",
|
393 |
+
description: "Here are some buttons",
|
394 |
+
},
|
395 |
+
},
|
396 |
{
|
397 |
element: "#scrollable-area",
|
398 |
popover: {
|
|
|
464 |
const driverObj = driver({
|
465 |
animate: true,
|
466 |
steps: basicTourSteps,
|
467 |
+
disableActiveInteraction: true,
|
468 |
showProgress: true,
|
469 |
progressText: "{{current}} of {{total}} done",
|
470 |
onPopoverRender: (popover) => {
|
src/config.ts
CHANGED
@@ -15,6 +15,8 @@ export type Config = {
|
|
15 |
stagePadding?: number;
|
16 |
stageRadius?: number;
|
17 |
|
|
|
|
|
18 |
allowKeyboardControl?: boolean;
|
19 |
|
20 |
// Popover specific configuration
|
@@ -54,6 +56,7 @@ export function configure(config: Config = {}) {
|
|
54 |
allowClose: true,
|
55 |
overlayOpacity: 0.7,
|
56 |
smoothScroll: false,
|
|
|
57 |
showProgress: false,
|
58 |
stagePadding: 10,
|
59 |
stageRadius: 5,
|
|
|
15 |
stagePadding?: number;
|
16 |
stageRadius?: number;
|
17 |
|
18 |
+
disableActiveInteraction?: boolean;
|
19 |
+
|
20 |
allowKeyboardControl?: boolean;
|
21 |
|
22 |
// Popover specific configuration
|
|
|
56 |
allowClose: true,
|
57 |
overlayOpacity: 0.7,
|
58 |
smoothScroll: false,
|
59 |
+
disableActiveInteraction: false,
|
60 |
showProgress: false,
|
61 |
stagePadding: 10,
|
62 |
stageRadius: 5,
|
src/driver.css
CHANGED
@@ -80,7 +80,8 @@
|
|
80 |
transition-duration: 200ms;
|
81 |
}
|
82 |
|
83 |
-
.driver-popover-close-btn:hover,
|
|
|
84 |
color: #2d2d2d;
|
85 |
}
|
86 |
|
@@ -140,7 +141,12 @@
|
|
140 |
overflow: hidden !important;
|
141 |
}
|
142 |
|
143 |
-
.driver-
|
|
|
|
|
|
|
|
|
|
|
144 |
background-color: #f7f7f7;
|
145 |
}
|
146 |
|
|
|
80 |
transition-duration: 200ms;
|
81 |
}
|
82 |
|
83 |
+
.driver-popover-close-btn:hover,
|
84 |
+
.driver-popover-close-btn:focus {
|
85 |
color: #2d2d2d;
|
86 |
}
|
87 |
|
|
|
141 |
overflow: hidden !important;
|
142 |
}
|
143 |
|
144 |
+
.driver-no-interaction, .driver-no-interaction * {
|
145 |
+
pointer-events: none !important;
|
146 |
+
}
|
147 |
+
|
148 |
+
.driver-popover-footer button:hover,
|
149 |
+
.driver-popover-footer button:focus {
|
150 |
background-color: #f7f7f7;
|
151 |
}
|
152 |
|
src/highlight.ts
CHANGED
@@ -146,11 +146,16 @@ function transferHighlight(toElement: Element, toStep: DriveStep) {
|
|
146 |
renderPopover(toElement, toStep);
|
147 |
}
|
148 |
|
149 |
-
fromElement.classList.remove("driver-active-element");
|
150 |
fromElement.removeAttribute("aria-haspopup");
|
151 |
fromElement.removeAttribute("aria-expanded");
|
152 |
fromElement.removeAttribute("aria-controls");
|
153 |
|
|
|
|
|
|
|
|
|
|
|
154 |
toElement.classList.add("driver-active-element");
|
155 |
toElement.setAttribute("aria-haspopup", "dialog");
|
156 |
toElement.setAttribute("aria-expanded", "true");
|
@@ -160,7 +165,7 @@ function transferHighlight(toElement: Element, toStep: DriveStep) {
|
|
160 |
export function destroyHighlight() {
|
161 |
document.getElementById("driver-dummy-element")?.remove();
|
162 |
document.querySelectorAll(".driver-active-element").forEach(element => {
|
163 |
-
element.classList.remove("driver-active-element");
|
164 |
element.removeAttribute("aria-haspopup");
|
165 |
element.removeAttribute("aria-expanded");
|
166 |
element.removeAttribute("aria-controls");
|
|
|
146 |
renderPopover(toElement, toStep);
|
147 |
}
|
148 |
|
149 |
+
fromElement.classList.remove("driver-active-element", "driver-no-interaction");
|
150 |
fromElement.removeAttribute("aria-haspopup");
|
151 |
fromElement.removeAttribute("aria-expanded");
|
152 |
fromElement.removeAttribute("aria-controls");
|
153 |
|
154 |
+
const disableActiveInteraction = getConfig("disableActiveInteraction");
|
155 |
+
if (disableActiveInteraction) {
|
156 |
+
toElement.classList.add("driver-no-interaction");
|
157 |
+
}
|
158 |
+
|
159 |
toElement.classList.add("driver-active-element");
|
160 |
toElement.setAttribute("aria-haspopup", "dialog");
|
161 |
toElement.setAttribute("aria-expanded", "true");
|
|
|
165 |
export function destroyHighlight() {
|
166 |
document.getElementById("driver-dummy-element")?.remove();
|
167 |
document.querySelectorAll(".driver-active-element").forEach(element => {
|
168 |
+
element.classList.remove("driver-active-element", "driver-no-interaction");
|
169 |
element.removeAttribute("aria-haspopup");
|
170 |
element.removeAttribute("aria-expanded");
|
171 |
element.removeAttribute("aria-controls");
|
src/utils.ts
CHANGED
@@ -18,7 +18,9 @@ export function getFocusableElements(parentEls: Element[] | HTMLElement[]) {
|
|
18 |
|
19 |
return [...(isParentFocusable ? [parentEl as HTMLElement] : []), ...focusableEls];
|
20 |
})
|
21 |
-
.filter(el =>
|
|
|
|
|
22 |
}
|
23 |
|
24 |
export function bringInView(element: Element) {
|
|
|
18 |
|
19 |
return [...(isParentFocusable ? [parentEl as HTMLElement] : []), ...focusableEls];
|
20 |
})
|
21 |
+
.filter(el => {
|
22 |
+
return getComputedStyle(el).pointerEvents !== "none" && isElementVisible(el);
|
23 |
+
});
|
24 |
}
|
25 |
|
26 |
export function bringInView(element: Element) {
|