You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: Add support for initialization onBeforeMount ✨ (#37)
* feat: Add support for initialization onBeforeMount ✨
- If onBeforeMount is true, initialization occurs onBeforeMount.
- Otherwise, the composable initializes onMounted
* Minor refactor. Also replaces relative imports
# Enhance User Engagement with Exit Intent Detection.
2
+
2
3
### A composable to show your modal when a user is about to leave the page or another threshold reached.
4
+
3
5
[Demo](https://vue-exit-intent.netlify.app/)
4
6
5
7
The very first version of this package created in favor of [this](https://dev.to/nickap/exit-intent-pop-up-how-to-publish-on-npm-vue-3-3bhm) old guide. [Here](https://dev.to/nickap/use-vue-exit-intent-a-vue-composable-to-power-your-exit-intent-content-4hlh) is an updated article regarding the latest version.
6
8
7
9
# Usage
10
+
8
11
### Import the composable and show your content according to the value of `isShowing`.
12
+
9
13
## Add the package
14
+
10
15
```
11
16
npm i vue-exit-intent
12
17
```
18
+
13
19
## Use the composable
14
-
```javascript
20
+
21
+
```javascript
15
22
<sript setup lang="ts">
16
23
import { useVueExitIntent } from'vue-exit-intent'
17
24
@@ -22,15 +29,18 @@ const options = {
22
29
23
30
const { isShowing, close } =useVueExitIntent(options);
After how many days you want the popup to get triggered again.
66
-
When a user gets the popup that exact timestamp is stored in localstorage and its taken into account next time the user will visit your page.
67
-
Giving a zero, the popup will be shown only once! Until the localstrage of the user gets cleared/resets.
68
-
**Give 0 to disable.**
69
-
**This one runs a CHECK before show.**
80
+
After how many days you want the popup to get triggered again.
81
+
When a user gets the popup that exact timestamp is stored in localstorage and its taken into account next time the user will visit your page.
82
+
Giving a zero, the popup will be shown only once! Until the localstrage of the user gets cleared/resets.
83
+
**Give 0 to disable.**
84
+
**This one runs a CHECK before show.**
70
85
71
86
-**scrollPercentageToTrigger**
72
-
A scroll percentage that if reached by the user, the pop-up will get triggered.
73
-
**Give 0 to disable.**
74
-
**This one TRIGGERS the popup.**
87
+
A scroll percentage that if reached by the user, the pop-up will get triggered.
88
+
**Give 0 to disable.**
89
+
**This one TRIGGERS the popup.**
75
90
76
91
-**delaySecondsAndTrigger**
77
-
Trigger the pop-up after a short delay in seconds, once the page has loaded.
78
-
**Give 0 to disable.**
79
-
**This one TRIGGERS the popup.**
92
+
Trigger the pop-up after a short delay in seconds, once the page has loaded.
93
+
**Give 0 to disable.**
94
+
**This one TRIGGERS the popup.**
80
95
81
96
-**touchDeviceSensitivity**
82
-
On touch devices where there is no mouseleave event, the popup will get triggered on fast (touch)scroll up.
83
-
The larger the number you will give, the more sesitive will be the pop-up on touch devices.
84
-
**Give 0 to disable.**
85
-
**This one TRIGGERS the popup on touch devices.**
97
+
On touch devices where there is no mouseleave event, the popup will get triggered on fast (touch)scroll up.
98
+
The larger the number you will give, the more sesitive will be the pop-up on touch devices.
99
+
**Give 0 to disable.**
100
+
**This one TRIGGERS the popup on touch devices.**
86
101
87
102
-**triggerOnExitIntent**
88
-
If false. Mouse out event, and scroll-up-fast for touch devices, will not trigger the pop-up. The user would have to reach delaySecondsAndTrigger or scrollPercentageToTrigger to get the popup.
89
-
If true, your modal pop-up is set to get triggered on user exit-intent.
90
-
**This one TRIGGERS the popup.**
103
+
If false. Mouse out event, and scroll-up-fast for touch devices, will not trigger the pop-up. The user would have to reach delaySecondsAndTrigger or scrollPercentageToTrigger to get the popup.
104
+
If true, your modal pop-up is set to get triggered on user exit-intent.
105
+
**This one TRIGGERS the popup.**
91
106
92
107
-**scrollDebounceMillis**
93
-
Time in milliseconds to debounce user's scrolling
108
+
Time in milliseconds to debounce user's scrolling
94
109
95
110
-**triggerOnPageLoad**
96
-
Show your modal pop-up immediately When a user visits your page.
97
-
**This one TRIGGERS the popup.**
111
+
Show your modal pop-up immediately When a user visits your page.
112
+
**This one TRIGGERS the popup.**
98
113
99
114
-**handleScrollBars**
100
-
Composable will handle the value of: `document.body.style.overflowY`.
101
-
Will be eather `auto` (when isShowing is `false`), or `hidden` (when isShowing is `true`)
115
+
Composable will handle the value of: `document.body.style.overflowY`.
116
+
Will be eather `auto` (when isShowing is `false`), or `hidden` (when isShowing is `true`)
102
117
103
118
-**LSItemKey**
104
-
Key of Local Storage item.
105
-
You can use a different key to show multiple pop-ups with different behaviour/content.
119
+
Key of Local Storage item.
120
+
You can use a different key to show multiple pop-ups with different behaviour/content.
121
+
122
+
-**setupBeforeMount**
123
+
Determines whether the initialization of the composable occurs during the `onBeforeMount` lifecycle hook instead of the default `onMounted` hook.
124
+
This options allows you to set up the exit intent before your component is mounted.
106
125
107
126
## Contribute
108
-
Feel free to contribute, message me for your ideas.
109
-
- Write tests.
110
-
- Report bugs.
111
-
- Share this project.
112
-
- Give a star if you like it.
113
-
- Improve the documentation.
127
+
128
+
Feel free to contribute, message me for your ideas.
See [Vite Configuration Reference](https://vitejs.dev/config/).
170
+
148
171
## License
172
+
149
173
```
150
174
The MIT License (MIT)
151
175
@@ -156,4 +180,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
156
180
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
157
181
158
182
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments