-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.vue
97 lines (87 loc) · 2.12 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<script lang="ts" setup>
import { useVueExitIntent } from '@/composables/useVueExitIntent.js';
const options = {
handleScrollBars: true,
inactiveSeconds: 3
};
const {
isShowing,
isAllowedToGetTriggered,
isUnsubscribed,
close,
resetState,
unsubscribe
} = useVueExitIntent(options);
</script>
<template>
<div id="demo-page">
<h1>Vue Exit Intent Demo Page</h1>
<p>
<b>Desktop</b>: Wait 3 seconds and move your mouse outside the
document.<br />
<b>Touch Device</b>: Wait 3 seconds and after you scroll down the
document, scroll up fast.
</p>
<p>
Do you want to unsubscribe from this popup, and to not trigger in the
future?
<button @click="unsubscribe">Unsubscribe</button>
</p>
<p>
Do you want to trigger the Pop-up again? <br />This Method will remove the
localStorage entry and reset the state of the plugin
<button @click="resetState">Reset State</button>
</p>
<pre>options: {{ options }}</pre>
<div class="current-state">
<p><strong>Current State:</strong></p>
<p>isShowing: {{ isShowing }}</p>
<p>isAllowedToGetTriggered: {{ isAllowedToGetTriggered }}</p>
<p>isUnsubscribed: {{ isUnsubscribed }}</p>
</div>
<dialog :open="isShowing">
<p>Exit intent detected!</p>
<form method="dialog">
<button value="ok" @click="close()">OK</button>
</form>
</dialog>
</div>
</template>
<style scoped>
#demo-page {
height: 1920px;
display: flex;
flex-direction: column;
background: repeating-linear-gradient(
45deg,
rgba(211, 211, 211, 0.1),
rgba(211, 211, 211, 0.1) 10px,
white 10px,
white 20px
);
display: flex;
flex-direction: column;
padding: 20px;
}
.current-state {
font-family: monospace;
background-color: white;
border-radius: 4px;
padding: 16px 32px;
max-width: 100%;
overflow-x: auto;
font-size: 14px;
}
dialog {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: none;
padding: 20px;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.3);
background: white;
border-radius: 8px;
margin: 0;
}
</style>