Add support for hiding buttons
Browse files- index.html +331 -311
- src/config.ts +2 -0
- src/popover.ts +14 -1
index.html
CHANGED
@@ -1,40 +1,57 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
* {
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
|
14 |
body {
|
15 |
-
|
16 |
"Helvetica Neue", sans-serif;
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
p {
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
|
27 |
.page-header {
|
28 |
-
|
29 |
-
|
30 |
}
|
31 |
|
32 |
.container {
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
}
|
39 |
|
40 |
h1,
|
@@ -43,325 +60,328 @@
|
|
43 |
h4,
|
44 |
h5,
|
45 |
h6 {
|
46 |
-
|
47 |
}
|
48 |
|
49 |
h1 {
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
}
|
54 |
|
55 |
h1 sup {
|
56 |
-
|
57 |
-
|
58 |
}
|
59 |
|
60 |
ul {
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
}
|
66 |
|
67 |
ul li:before {
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
72 |
.buttons {
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
|
80 |
button {
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
}
|
88 |
|
89 |
pre {
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
}
|
97 |
|
98 |
#scrollable-area {
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
}
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
yarn add driver.js
|
153 |
npm install driver.js</pre
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
});
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
align: "end",
|
273 |
-
side: "top",
|
274 |
-
},
|
275 |
-
});
|
276 |
-
});
|
277 |
-
|
278 |
-
document.getElementById("dark-highlight-btn").addEventListener("click", () => {
|
279 |
-
driver({
|
280 |
-
animate: true,
|
281 |
-
opacity: 0.9,
|
282 |
-
}).highlight({ element: "ul" });
|
283 |
});
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
document.getElementById("transition-highlight-btn").addEventListener("click", () => {
|
293 |
-
const driverObj = driver({ animate: true });
|
294 |
-
|
295 |
-
driverObj.highlight({
|
296 |
-
popover: {
|
297 |
-
title: "driver.js",
|
298 |
-
description: "Highlight anything, anywhere on the page",
|
299 |
-
},
|
300 |
-
});
|
301 |
-
|
302 |
-
window.setTimeout(() => {
|
303 |
-
driverObj.highlight({
|
304 |
-
element: ".buttons button:first-child",
|
305 |
-
popover: {
|
306 |
-
title: "driver.js",
|
307 |
-
description: "Highlight anything, anywhere on the page",
|
308 |
-
},
|
309 |
-
});
|
310 |
-
}, 2000);
|
311 |
-
|
312 |
-
window.setTimeout(() => {
|
313 |
-
driverObj.highlight({
|
314 |
-
popover: {
|
315 |
-
title: "driver.js",
|
316 |
-
description: "Highlight anything, anywhere on the page",
|
317 |
-
},
|
318 |
-
});
|
319 |
-
}, 4000);
|
320 |
-
|
321 |
-
window.setTimeout(() => {
|
322 |
-
driverObj.highlight({
|
323 |
-
element: "h2",
|
324 |
-
popover: {
|
325 |
-
description: "driver.js",
|
326 |
-
},
|
327 |
-
});
|
328 |
-
}, 6000);
|
329 |
-
});
|
330 |
-
|
331 |
-
document.getElementById("scrollable-area-btn").addEventListener("click", () => {
|
332 |
-
const driverObj = driver({ animate: true });
|
333 |
-
driverObj.highlight({ element: "#scrollable-area" });
|
334 |
-
});
|
335 |
-
|
336 |
-
document.getElementById("without-element-btn").addEventListener("click", () => {
|
337 |
-
const driverObj = driver({ animate: true });
|
338 |
-
driverObj.highlight({
|
339 |
-
popover: {
|
340 |
-
title: "driver.js",
|
341 |
-
description: "Highlight anything, anywhere on the page",
|
342 |
-
},
|
343 |
-
});
|
344 |
-
});
|
345 |
-
|
346 |
-
document.getElementById("inner-scroll-area-btn").addEventListener("click", () => {
|
347 |
-
const driverObj = driver({ animate: true });
|
348 |
-
driverObj.highlight({ element: "#third-scroll-paragraph" });
|
349 |
-
});
|
350 |
-
|
351 |
-
document.getElementById("disallow-close").addEventListener("click", () => {
|
352 |
-
const driverObj = driver({
|
353 |
-
animate: true,
|
354 |
-
allowClose: false,
|
355 |
-
});
|
356 |
-
|
357 |
-
driverObj.highlight({
|
358 |
-
element: ".buttons",
|
359 |
-
});
|
360 |
-
});
|
361 |
-
|
362 |
-
document.getElementById("destroy-btn").addEventListener("click", () => {
|
363 |
-
driver().destroy();
|
364 |
});
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Vite App</title>
|
7 |
|
8 |
+
<style>
|
9 |
* {
|
10 |
+
margin: 0;
|
11 |
+
padding: 0;
|
12 |
}
|
13 |
|
14 |
body {
|
15 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
|
16 |
"Helvetica Neue", sans-serif;
|
17 |
+
font-size: 14px;
|
18 |
+
-webkit-font-smoothing: antialiased;
|
19 |
+
-moz-osx-font-smoothing: grayscale;
|
20 |
+
}
|
21 |
+
|
22 |
+
.gif-popover {
|
23 |
+
display: flex;
|
24 |
+
flex-direction: column;
|
25 |
+
text-align: center;
|
26 |
+
}
|
27 |
+
|
28 |
+
.gif-popover img {
|
29 |
+
width: 100%;
|
30 |
+
height: auto;
|
31 |
+
margin-bottom: 10px;
|
32 |
+
}
|
33 |
+
|
34 |
+
.gif-popover p {
|
35 |
+
font-weight: 500;
|
36 |
+
margin-bottom: 0;
|
37 |
}
|
38 |
|
39 |
p {
|
40 |
+
line-height: 1.5;
|
41 |
+
margin-bottom: 15px;
|
42 |
}
|
43 |
|
44 |
.page-header {
|
45 |
+
text-align: center;
|
46 |
+
margin-bottom: 10px;
|
47 |
}
|
48 |
|
49 |
.container {
|
50 |
+
display: flex;
|
51 |
+
flex-direction: column;
|
52 |
+
max-width: 500px;
|
53 |
+
margin: 0 auto;
|
54 |
+
text-align: left;
|
55 |
}
|
56 |
|
57 |
h1,
|
|
|
60 |
h4,
|
61 |
h5,
|
62 |
h6 {
|
63 |
+
margin: 30px 0 10px;
|
64 |
}
|
65 |
|
66 |
h1 {
|
67 |
+
font-size: 48px;
|
68 |
+
font-weight: 600;
|
69 |
+
text-align: center;
|
70 |
}
|
71 |
|
72 |
h1 sup {
|
73 |
+
font-size: 18px;
|
74 |
+
font-weight: 400;
|
75 |
}
|
76 |
|
77 |
ul {
|
78 |
+
list-style: none;
|
79 |
+
padding: 0;
|
80 |
+
margin: 20px 10px 0;
|
81 |
+
line-height: 1.5;
|
82 |
}
|
83 |
|
84 |
ul li:before {
|
85 |
+
content: "•";
|
86 |
+
margin-right: 10px;
|
87 |
}
|
88 |
|
89 |
.buttons {
|
90 |
+
display: flex;
|
91 |
+
margin-top: 20px;
|
92 |
+
gap: 10px;
|
93 |
+
max-width: 500px;
|
94 |
+
flex-wrap: wrap;
|
95 |
}
|
96 |
|
97 |
button {
|
98 |
+
all: unset;
|
99 |
+
border: 1px solid #ccc;
|
100 |
+
padding: 5px 15px;
|
101 |
+
border-radius: 5px;
|
102 |
+
display: block;
|
103 |
+
cursor: pointer;
|
104 |
}
|
105 |
|
106 |
pre {
|
107 |
+
margin-bottom: 20px;
|
108 |
+
border: 1px solid #ccc;
|
109 |
+
background: whitesmoke;
|
110 |
+
border-radius: 5px;
|
111 |
+
padding: 10px;
|
112 |
+
line-height: 1.75;
|
113 |
}
|
114 |
|
115 |
#scrollable-area {
|
116 |
+
height: 300px;
|
117 |
+
overflow: auto;
|
118 |
+
border: 1px solid #ccc;
|
119 |
+
padding: 10px;
|
120 |
+
border-radius: 5px;
|
121 |
+
margin: 50px 0;
|
122 |
}
|
123 |
+
</style>
|
124 |
+
</head>
|
125 |
+
<body>
|
126 |
+
<div class="container">
|
127 |
+
<div class="page-header">
|
128 |
+
<h1>driver.js <sup>next</sup></h1>
|
129 |
+
<p>Rewritten and enhanced version of driver.js</p>
|
130 |
+
</div>
|
131 |
+
|
132 |
+
<div class="buttons">
|
133 |
+
<button id="highlight-btn">Animated Highlight</button>
|
134 |
+
<button id="simple-highlight-btn">Simple Highlight</button>
|
135 |
+
<button id="transition-highlight-btn">Transition Highlight</button>
|
136 |
+
<button id="disallow-close">Disallow Close</button>
|
137 |
+
<button id="dark-highlight-btn">Super Dark Highlight</button>
|
138 |
+
<button id="dim-highlight-btn">Super Dim Highlight</button>
|
139 |
+
<button id="scrollable-area-btn">Scrollable Area</button>
|
140 |
+
<button id="inner-scroll-area-btn">Inner Scroll Area</button>
|
141 |
+
<button id="without-element-btn">No Element</button>
|
142 |
+
<button id="destroy-btn">Destroy</button>
|
143 |
+
</div>
|
144 |
+
|
145 |
+
<ul>
|
146 |
+
<li>Written in TypeScript</li>
|
147 |
+
<li>Lightweight — only 5kb gzipped</li>
|
148 |
+
<li>No dependencies</li>
|
149 |
+
<li>MIT Licensed</li>
|
150 |
+
</ul>
|
151 |
+
|
152 |
+
<h2>Yet another Tour Library?</h2>
|
153 |
+
<p>
|
154 |
+
No, it is not. Tours are just one of the many use-cases. Driver.js can be used wherever you need some sort of
|
155 |
+
overlay for the page; some common usecases could be: e.g. dimming the background when user is interacting with
|
156 |
+
some component, using it as a focus shifter to bring user's attention to some component on page, or using it to
|
157 |
+
simulate those "Turn off the Lights" widgets that you might have seen on video players online, etc.
|
158 |
+
</p>
|
159 |
+
<p class="second-para">
|
160 |
+
Driver.js is written in Vanilla JS, has zero dependencies and is highly customizable. It has several options
|
161 |
+
allowing you to manipulate how it behaves and also provides you the hooks to manipulate the elements as they are
|
162 |
+
highlighted, about to be highlighted, or deselected.
|
163 |
+
</p>
|
164 |
+
|
165 |
+
<h2 id="installation-head">Installation</h2>
|
166 |
+
<p>You can install it using yarn or npm, whatever you prefer.</p>
|
167 |
+
|
168 |
+
<pre>
|
169 |
yarn add driver.js
|
170 |
npm install driver.js</pre
|
171 |
+
>
|
172 |
+
|
173 |
+
<p>Or include it using CDN — put the version as [email protected] in the name</p>
|
174 |
+
|
175 |
+
<pre>https://unpkg.com/driver.js/dist/driver.min.js</pre>
|
176 |
+
|
177 |
+
<h2>Usage and Demo</h2>
|
178 |
+
|
179 |
+
<p id="large-paragraph-text">
|
180 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
181 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
182 |
+
tempore voluptates! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea
|
183 |
+
eligendi id in inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi
|
184 |
+
recusandae tempore voluptates!
|
185 |
+
</p>
|
186 |
+
<p>
|
187 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
188 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
189 |
+
tempore voluptates!
|
190 |
+
</p>
|
191 |
+
<p>
|
192 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
193 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
194 |
+
tempore voluptates!
|
195 |
+
</p>
|
196 |
+
<div id="scrollable-area">
|
197 |
+
<p>
|
198 |
+
First -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
199 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
200 |
+
veniam! Doloribus eos id quaerat.
|
201 |
+
</p>
|
202 |
+
<p>
|
203 |
+
Second -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
204 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
205 |
+
veniam! Doloribus eos id quaerat.
|
206 |
+
</p>
|
207 |
+
<p id="third-scroll-paragraph">
|
208 |
+
Third -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
209 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
210 |
+
veniam! Doloribus eos id quaerat.
|
211 |
+
</p>
|
212 |
+
<p>
|
213 |
+
Fourth -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
214 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
215 |
+
veniam! Doloribus eos id quaerat.
|
216 |
+
</p>
|
217 |
+
<p>
|
218 |
+
Fifth -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
219 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
220 |
+
veniam! Doloribus eos id quaerat.
|
221 |
+
</p>
|
222 |
+
<p>
|
223 |
+
Sixth -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
224 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
225 |
+
veniam! Doloribus eos id quaerat.
|
226 |
+
</p>
|
227 |
+
<p>
|
228 |
+
Seventh -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
229 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
230 |
+
veniam! Doloribus eos id quaerat.
|
231 |
+
</p>
|
232 |
+
<p>
|
233 |
+
Eighth -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
234 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
235 |
+
veniam! Doloribus eos id quaerat.
|
236 |
+
</p>
|
237 |
+
<p>
|
238 |
+
Ninth -> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur dicta ipsum labore quod
|
239 |
+
tempora ullam? Alias consequatur doloremque laborum maxime necessitatibus nostrum odio, officiis quibusdam
|
240 |
+
veniam! Doloribus eos id quaerat.
|
241 |
+
</p>
|
242 |
+
</div>
|
243 |
+
<p>
|
244 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
245 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
246 |
+
tempore voluptates!
|
247 |
+
</p>
|
248 |
+
<p>
|
249 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
250 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
251 |
+
tempore voluptates!
|
252 |
+
</p>
|
253 |
+
<p>
|
254 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
255 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
256 |
+
tempore voluptates!
|
257 |
+
</p>
|
258 |
+
<p>
|
259 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
260 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
261 |
+
tempore voluptates!
|
262 |
+
</p>
|
263 |
+
<p>
|
264 |
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi blanditiis consectetur ea eligendi id in
|
265 |
+
inventore ipsa iure laudantium libero, minus molestias necessitatibus nesciunt non omnis, quasi recusandae
|
266 |
+
tempore voluptates!
|
267 |
+
</p>
|
268 |
+
</div>
|
269 |
+
<script type="module">
|
270 |
+
import { driver } from "./src/driver.ts";
|
271 |
+
|
272 |
+
document.getElementById("highlight-btn").addEventListener("click", () => {
|
273 |
+
driver({ animate: true }).highlight({
|
274 |
+
element: "h2",
|
275 |
+
popover: {
|
276 |
+
title: "MIT License",
|
277 |
+
description: "A <strong>lightweight, no-dependency</strong> JavaScript engine to drive user's focus.",
|
278 |
+
},
|
279 |
+
});
|
280 |
+
});
|
281 |
+
|
282 |
+
document.getElementById("simple-highlight-btn").addEventListener("click", () => {
|
283 |
+
driver({ animate: false }).highlight({
|
284 |
+
element: "#large-paragraph-text",
|
285 |
+
popover: {
|
286 |
+
title: "driver.js",
|
287 |
+
description:
|
288 |
+
"Highlight anything, anywhere on the page. Yes, literally anything including SVG portions, scrollable items etc.",
|
289 |
+
align: "end",
|
290 |
+
side: "top",
|
291 |
+
},
|
292 |
+
});
|
293 |
+
});
|
294 |
+
|
295 |
+
document.getElementById("dark-highlight-btn").addEventListener("click", () => {
|
296 |
+
driver({
|
297 |
+
animate: true,
|
298 |
+
opacity: 0.9,
|
299 |
+
}).highlight({ element: "ul" });
|
300 |
+
});
|
301 |
+
|
302 |
+
document.getElementById("dim-highlight-btn").addEventListener("click", () => {
|
303 |
+
driver({
|
304 |
+
animate: true,
|
305 |
+
opacity: 0.2,
|
306 |
+
}).highlight({ element: ".buttons" });
|
307 |
+
});
|
308 |
+
|
309 |
+
document.getElementById("transition-highlight-btn").addEventListener("click", () => {
|
310 |
+
const driverObj = driver({ animate: true });
|
311 |
+
|
312 |
+
driverObj.highlight({
|
313 |
+
popover: {
|
314 |
+
title: "driver.js",
|
315 |
+
description: "Highlight anything, anywhere on the page",
|
316 |
+
},
|
317 |
+
});
|
318 |
+
|
319 |
+
window.setTimeout(() => {
|
320 |
+
driverObj.highlight({
|
321 |
+
element: ".buttons button:first-child",
|
322 |
+
popover: {
|
323 |
+
title: "driver.js",
|
324 |
+
description: "Highlight anything, anywhere on the page",
|
325 |
+
},
|
326 |
});
|
327 |
+
}, 2000);
|
328 |
+
|
329 |
+
window.setTimeout(() => {
|
330 |
+
driverObj.highlight({
|
331 |
+
popover: {
|
332 |
+
title: "driver.js",
|
333 |
+
description: "Highlight anything, anywhere on the page",
|
334 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
});
|
336 |
+
}, 4000);
|
337 |
+
|
338 |
+
window.setTimeout(() => {
|
339 |
+
driverObj.highlight({
|
340 |
+
element: "h2",
|
341 |
+
popover: {
|
342 |
+
description: "driver.js",
|
343 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
});
|
345 |
+
}, 6000);
|
346 |
+
});
|
347 |
+
|
348 |
+
document.getElementById("scrollable-area-btn").addEventListener("click", () => {
|
349 |
+
const driverObj = driver({ animate: true });
|
350 |
+
driverObj.highlight({ element: "#scrollable-area" });
|
351 |
+
});
|
352 |
+
|
353 |
+
document.getElementById("without-element-btn").addEventListener("click", () => {
|
354 |
+
const driverObj = driver({
|
355 |
+
animate: true,
|
356 |
+
});
|
357 |
+
driverObj.highlight({
|
358 |
+
popover: {
|
359 |
+
showButtons: false,
|
360 |
+
description:
|
361 |
+
"<div class='gif-popover'><img style='max-width: 100%' src='https://i.imgur.com/EAQhHu5.gif' /><p>Go and build something cool!</p></div>",
|
362 |
+
},
|
363 |
+
});
|
364 |
+
});
|
365 |
+
|
366 |
+
document.getElementById("inner-scroll-area-btn").addEventListener("click", () => {
|
367 |
+
const driverObj = driver({ animate: true });
|
368 |
+
driverObj.highlight({ element: "#third-scroll-paragraph" });
|
369 |
+
});
|
370 |
+
|
371 |
+
document.getElementById("disallow-close").addEventListener("click", () => {
|
372 |
+
const driverObj = driver({
|
373 |
+
animate: true,
|
374 |
+
allowClose: false,
|
375 |
+
});
|
376 |
+
|
377 |
+
driverObj.highlight({
|
378 |
+
element: ".buttons",
|
379 |
+
});
|
380 |
+
});
|
381 |
+
|
382 |
+
document.getElementById("destroy-btn").addEventListener("click", () => {
|
383 |
+
driver().destroy();
|
384 |
+
});
|
385 |
+
</script>
|
386 |
+
</body>
|
387 |
</html>
|
src/config.ts
CHANGED
@@ -6,6 +6,7 @@ export type Config = {
|
|
6 |
stagePadding?: number;
|
7 |
stageRadius?: number;
|
8 |
popoverOffset?: number;
|
|
|
9 |
};
|
10 |
|
11 |
let currentConfig: Config = {};
|
@@ -19,6 +20,7 @@ export function configure(config: Config = {}) {
|
|
19 |
stagePadding: 10,
|
20 |
stageRadius: 5,
|
21 |
popoverOffset: 10,
|
|
|
22 |
...config,
|
23 |
};
|
24 |
}
|
|
|
6 |
stagePadding?: number;
|
7 |
stageRadius?: number;
|
8 |
popoverOffset?: number;
|
9 |
+
showButtons?: boolean;
|
10 |
};
|
11 |
|
12 |
let currentConfig: Config = {};
|
|
|
20 |
stagePadding: 10,
|
21 |
stageRadius: 5,
|
22 |
popoverOffset: 10,
|
23 |
+
showButtons: true,
|
24 |
...config,
|
25 |
};
|
26 |
}
|
src/popover.ts
CHANGED
@@ -11,6 +11,7 @@ export type Popover = {
|
|
11 |
description: string;
|
12 |
side?: Side;
|
13 |
align?: Alignment;
|
|
|
14 |
};
|
15 |
|
16 |
export type PopoverDOM = {
|
@@ -41,7 +42,7 @@ export function renderPopover(element: Element, step: DriveStep) {
|
|
41 |
document.body.appendChild(popover.wrapper);
|
42 |
}
|
43 |
|
44 |
-
const { title, description } = step.popover || {};
|
45 |
|
46 |
if (title) {
|
47 |
popover.title.innerText = title;
|
@@ -57,6 +58,18 @@ export function renderPopover(element: Element, step: DriveStep) {
|
|
57 |
popover.description.style.display = "none";
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
// Reset the popover position
|
61 |
const popoverWrapper = popover.wrapper;
|
62 |
popoverWrapper.style.display = "block";
|
|
|
11 |
description: string;
|
12 |
side?: Side;
|
13 |
align?: Alignment;
|
14 |
+
showButtons?: boolean;
|
15 |
};
|
16 |
|
17 |
export type PopoverDOM = {
|
|
|
42 |
document.body.appendChild(popover.wrapper);
|
43 |
}
|
44 |
|
45 |
+
const { title, description, showButtons = undefined } = step.popover || {};
|
46 |
|
47 |
if (title) {
|
48 |
popover.title.innerText = title;
|
|
|
58 |
popover.description.style.display = "none";
|
59 |
}
|
60 |
|
61 |
+
if (getConfig("showButtons") === true) {
|
62 |
+
popover.footer.style.display = "flex";
|
63 |
+
} else {
|
64 |
+
popover.footer.style.display = "none";
|
65 |
+
}
|
66 |
+
|
67 |
+
if (showButtons === true) {
|
68 |
+
popover.footer.style.display = "flex";
|
69 |
+
} else if (showButtons === false) {
|
70 |
+
popover.footer.style.display = "none";
|
71 |
+
}
|
72 |
+
|
73 |
// Reset the popover position
|
74 |
const popoverWrapper = popover.wrapper;
|
75 |
popoverWrapper.style.display = "block";
|