Add prevent destroy example
Browse files
docs/src/content/guides/prevent-destroy.mdx
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: "Prevent Tour Exit"
|
3 |
+
groupTitle: "Examples"
|
4 |
+
sort: 3
|
5 |
+
---
|
6 |
+
|
7 |
+
import { CodeSample } from "../../components/CodeSample.tsx";
|
8 |
+
|
9 |
+
You can also prevent the user from exiting the tour using `allowClose` option. This option is useful when you want to force the user to complete the tour before they can exit.
|
10 |
+
|
11 |
+
In the example below, you won't be able to exit the tour until you reach the last step.
|
12 |
+
|
13 |
+
<CodeSample
|
14 |
+
heading={'Prevent Exit'}
|
15 |
+
config={{
|
16 |
+
animate: true,
|
17 |
+
showProgress: true,
|
18 |
+
allowClose: false,
|
19 |
+
showButtons: ['next', 'previous'],
|
20 |
+
}}
|
21 |
+
tour={[
|
22 |
+
{ element: '#prevent-exit', popover: { title: 'Animated Tour Example', description: 'Here is the code example showing animated tour. Let\'s walk you through it.', side: "left", align: 'start' }},
|
23 |
+
{ element: '.line:nth-child(1)', popover: { title: 'Import the Library', description: 'It works the same in vanilla JavaScript as well as frameworks.', side: "bottom", align: 'start' }},
|
24 |
+
{ element: '.line:nth-child(2)', popover: { title: 'Importing CSS', description: 'Import the CSS which gives you the default styling for popover and overlay.', side: "bottom", align: 'start' }},
|
25 |
+
{ popover: { title: 'Happy Coding', description: 'And that is all, go ahead and start adding tours to your applications.' } }
|
26 |
+
]}
|
27 |
+
id={"prevent-exit"}
|
28 |
+
client:load>
|
29 |
+
```js
|
30 |
+
import { driver } from "driver.js";
|
31 |
+
import "driver.js/dist/driver.css";
|
32 |
+
|
33 |
+
const driverObj = driver({
|
34 |
+
showProgress: true,
|
35 |
+
allowClose: false,
|
36 |
+
steps: [
|
37 |
+
{ element: '#prevent-exit', popover: { title: 'Animated Tour Example', description: 'Here is the code example showing animated tour. Let\'s walk you through it.', side: "left", align: 'start' }},
|
38 |
+
{ element: 'code .line:nth-child(1)', popover: { title: 'Import the Library', description: 'It works the same in vanilla JavaScript as well as frameworks.', side: "bottom", align: 'start' }},
|
39 |
+
{ element: 'code .line:nth-child(2)', popover: { title: 'Importing CSS', description: 'Import the CSS which gives you the default styling for popover and overlay.', side: "bottom", align: 'start' }},
|
40 |
+
{ popover: { title: 'Happy Coding', description: 'And that is all, go ahead and start adding tours to your applications.' } }
|
41 |
+
],
|
42 |
+
});
|
43 |
+
|
44 |
+
driverObj.drive();
|
45 |
+
```
|
46 |
+
</CodeSample>
|