kamrify commited on
Commit
e9a1e79
·
1 Parent(s): 34b7e3b

Add example for non-animated tour

Browse files
Files changed (2) hide show
  1. index.html +67 -54
  2. src/driver.ts +2 -1
index.html CHANGED
@@ -197,7 +197,8 @@
197
  <h2>Tour Feature</h2>
198
  <p>Examples below show the tour usage of driver.js.</p>
199
  <div class="buttons">
200
- <button id="basic-tour">Basic Tour</button>
 
201
  </div>
202
 
203
  <ul>
@@ -331,61 +332,73 @@ npm install driver.js</pre
331
  <script type="module">
332
  import { driver } from "./src/driver.ts";
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  document.getElementById("basic-tour").addEventListener("click", () => {
335
  const driverObj = driver({
336
- animate: true,
337
- steps: [
338
- {
339
- element: ".page-header",
340
- popover: {
341
- title: "New and Improved Driver.js",
342
- description:
343
- "Driver.js has been written from the ground up. The new version is more powerful, has less surprises, more customizable and tons of new features.",
344
- side: "bottom",
345
- align: "start",
346
- },
347
- },
348
- {
349
- element: ".page-header h1",
350
- popover: {
351
- title: "No Stacking Issues",
352
- description:
353
- "Unlike the older version, new version doesn't work with z-indexes so no more positional issues.",
354
- side: "left",
355
- align: "start",
356
- },
357
- },
358
- {
359
- element: ".page-header sup",
360
- popover: {
361
- title: "Improved Hooks",
362
- description:
363
- "Unlike the older version, new version doesn't work with z-indexes so no more positional issues.",
364
- side: "bottom",
365
- align: "start",
366
- },
367
- },
368
- {
369
- popover: {
370
- title: "No Element",
371
- description: "You can now have popovers without elements as well",
372
- },
373
- },
374
- {
375
- element: "#scrollable-area",
376
- popover: {
377
- title: "Scrollable Areas",
378
- description: "There are no issues with scrollable element tours as well."
379
- }
380
- },
381
- {
382
- element: "#third-scroll-paragraph",
383
- popover: {
384
- title: "Nested Scrolls",
385
- description: "Even the nested scrollable elements work now."
386
- }
387
- }
388
- ],
389
  });
390
 
391
  driverObj.drive();
 
197
  <h2>Tour Feature</h2>
198
  <p>Examples below show the tour usage of driver.js.</p>
199
  <div class="buttons">
200
+ <button id="basic-tour">Animated Tour</button>
201
+ <button id="non-animated-tour">Non-Animated Tour</button>
202
  </div>
203
 
204
  <ul>
 
332
  <script type="module">
333
  import { driver } from "./src/driver.ts";
334
 
335
+ const basicTourSteps = [
336
+ {
337
+ element: ".page-header",
338
+ popover: {
339
+ title: "New and Improved Driver.js",
340
+ description:
341
+ "Driver.js has been written from the ground up. The new version is more powerful, has less surprises, more customizable and tons of new features.",
342
+ side: "bottom",
343
+ align: "start",
344
+ },
345
+ },
346
+ {
347
+ element: ".page-header h1",
348
+ popover: {
349
+ title: "No Stacking Issues",
350
+ description:
351
+ "Unlike the older version, new version doesn't work with z-indexes so no more positional issues.",
352
+ side: "left",
353
+ align: "start",
354
+ },
355
+ },
356
+ {
357
+ element: ".page-header sup",
358
+ popover: {
359
+ title: "Improved Hooks",
360
+ description:
361
+ "Unlike the older version, new version doesn't work with z-indexes so no more positional issues.",
362
+ side: "bottom",
363
+ align: "start",
364
+ },
365
+ },
366
+ {
367
+ popover: {
368
+ title: "No Element",
369
+ description: "You can now have popovers without elements as well",
370
+ },
371
+ },
372
+ {
373
+ element: "#scrollable-area",
374
+ popover: {
375
+ title: "Scrollable Areas",
376
+ description: "There are no issues with scrollable element tours as well.",
377
+ },
378
+ },
379
+ {
380
+ element: "#third-scroll-paragraph",
381
+ popover: {
382
+ title: "Nested Scrolls",
383
+ description: "Even the nested scrollable elements work now.",
384
+ },
385
+ },
386
+ ];
387
+
388
+ document.getElementById("non-animated-tour").addEventListener("click", () => {
389
+ const driverObj = driver({
390
+ animate: false,
391
+ backdropColor: "blue",
392
+ opacity: 0.3,
393
+ steps: basicTourSteps,
394
+ });
395
+
396
+ driverObj.drive();
397
+ });
398
+
399
  document.getElementById("basic-tour").addEventListener("click", () => {
400
  const driverObj = driver({
401
+ steps: basicTourSteps,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  });
403
 
404
  driverObj.drive();
src/driver.ts CHANGED
@@ -88,11 +88,12 @@ export function driver(options: Config = {}) {
88
  const hasPreviousStep = steps[stepIndex - 1];
89
 
90
  const doneBtnText = currentStep.popover?.doneBtnText || getConfig("doneBtnText") || "Done";
 
91
 
92
  highlight({
93
  ...currentStep,
94
  popover: {
95
- showButtons: ["next", "previous", "close"],
96
  nextBtnText: !hasNextStep ? doneBtnText : undefined,
97
  disableButtons: [...(!hasPreviousStep ? ["previous" as AllowedButtons] : [])],
98
  onNextClick: () => {
 
88
  const hasPreviousStep = steps[stepIndex - 1];
89
 
90
  const doneBtnText = currentStep.popover?.doneBtnText || getConfig("doneBtnText") || "Done";
91
+ const allowsClosing = getConfig("allowClose");
92
 
93
  highlight({
94
  ...currentStep,
95
  popover: {
96
+ showButtons: ["next", "previous", ...(allowsClosing ? ["close" as AllowedButtons] : [])],
97
  nextBtnText: !hasNextStep ? doneBtnText : undefined,
98
  disableButtons: [...(!hasPreviousStep ? ["previous" as AllowedButtons] : [])],
99
  onNextClick: () => {