Add hooks demo
Browse files- index.html +50 -0
index.html
CHANGED
@@ -142,6 +142,7 @@
|
|
142 |
<button id="is-active-btn">Is Active?</button>
|
143 |
<button id="activate-check-btn">Activate and Check</button>
|
144 |
<button id="backdrop-color-btn">Backdrop Color</button>
|
|
|
145 |
<button id="destroy-btn">Destroy</button>
|
146 |
</div>
|
147 |
|
@@ -152,6 +153,10 @@
|
|
152 |
<li>MIT Licensed</li>
|
153 |
</ul>
|
154 |
|
|
|
|
|
|
|
|
|
155 |
<h2>Yet another Tour Library?</h2>
|
156 |
<p>
|
157 |
No, it is not. Tours are just one of the many use-cases. Driver.js can be used wherever you need some sort of
|
@@ -411,6 +416,51 @@ npm install driver.js</pre
|
|
411 |
}, 6000);
|
412 |
});
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
document.getElementById("scrollable-area-btn").addEventListener("click", () => {
|
415 |
const driverObj = driver({ animate: true });
|
416 |
driverObj.highlight({ element: "#scrollable-area" });
|
|
|
142 |
<button id="is-active-btn">Is Active?</button>
|
143 |
<button id="activate-check-btn">Activate and Check</button>
|
144 |
<button id="backdrop-color-btn">Backdrop Color</button>
|
145 |
+
<button id="hooks">Hooks</button>
|
146 |
<button id="destroy-btn">Destroy</button>
|
147 |
</div>
|
148 |
|
|
|
153 |
<li>MIT Licensed</li>
|
154 |
</ul>
|
155 |
|
156 |
+
<ul id="hooks-list">
|
157 |
+
<li><strong>Hooks Button Demo — </strong>List of hooks fired</li>
|
158 |
+
</ul>
|
159 |
+
|
160 |
<h2>Yet another Tour Library?</h2>
|
161 |
<p>
|
162 |
No, it is not. Tours are just one of the many use-cases. Driver.js can be used wherever you need some sort of
|
|
|
416 |
}, 6000);
|
417 |
});
|
418 |
|
419 |
+
document.getElementById("hooks").addEventListener("click", () => {
|
420 |
+
const hooksEl = document.getElementById("hooks-list");
|
421 |
+
|
422 |
+
const driverObj = driver({
|
423 |
+
animate: true,
|
424 |
+
onDeselected: (element, step) => {
|
425 |
+
const li = document.createElement("li");
|
426 |
+
// prettier-ignore
|
427 |
+
li.innerHTML = `Deselected: ${element.textContent?.slice(0, 10)}..<br> ${JSON.stringify(step)}..`;
|
428 |
+
hooksEl.append(li);
|
429 |
+
},
|
430 |
+
onHighlightStarted: (element, step) => {
|
431 |
+
const li = document.createElement("li");
|
432 |
+
// prettier-ignore
|
433 |
+
li.innerHTML = `Highlight Started: ${element.textContent?.slice(0, 10)}..<br> ${JSON.stringify(step)}..`;
|
434 |
+
hooksEl.append(li);
|
435 |
+
},
|
436 |
+
onHighlighted: (element, step) => {
|
437 |
+
const li = document.createElement("li");
|
438 |
+
// prettier-ignore
|
439 |
+
li.innerHTML = `Highlighted: ${element.textContent?.slice(0, 10)}..<br> ${JSON.stringify(step)}..`;
|
440 |
+
hooksEl.append(li);
|
441 |
+
},
|
442 |
+
onClose: (element, step) => {
|
443 |
+
const li = document.createElement("li");
|
444 |
+
// prettier-ignore
|
445 |
+
li.innerHTML = `Closed: ${element.textContent?.slice(0, 10)}..<br> ${JSON.stringify(step)}..`;
|
446 |
+
hooksEl.append(li);
|
447 |
+
},
|
448 |
+
});
|
449 |
+
|
450 |
+
driverObj.highlight({
|
451 |
+
element: "#hooks",
|
452 |
+
});
|
453 |
+
|
454 |
+
window.setTimeout(() => {
|
455 |
+
driverObj.highlight({
|
456 |
+
element: "#hooks-list",
|
457 |
+
popover: {
|
458 |
+
description: "Here are all the hooks",
|
459 |
+
},
|
460 |
+
});
|
461 |
+
}, 1000);
|
462 |
+
});
|
463 |
+
|
464 |
document.getElementById("scrollable-area-btn").addEventListener("click", () => {
|
465 |
const driverObj = driver({ animate: true });
|
466 |
driverObj.highlight({ element: "#scrollable-area" });
|