Socket
Socket
Sign inDemoInstall

vue-exit-intent

Package Overview
Dependencies
21
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-exit-intent

Exit Intent Composable. Show your content when a user is leaving, or another threshold reached.


Version published
Weekly downloads
62
decreased by-21.52%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Use Composition API to power your exit intent strategy.

A composable to show your content when a user is leaving, or another threshold reached.

Demo

This package created in favor of this guide.

Usage

Import the composable and show your modal according to the value of isShowing.

Add the package

npm i vue-exit-intent

Use the component like this

<sript setup lang="ts">
import { useVueExitIntent } from 'vue-exit-intent'

const options = {
  LSItemKey: 'local-storage-key',
  handleScrollBars: true
}

const { isShowing, close } = useVueExitIntent(options);
</script>
<template>
  <yourModalPopUp v-if="isShowing" @close="close"></yourModalPopUp>
</template>

Available helpers

If you use all available helpers your code would look like this:

const {
  isShowing,
  isAllowedToGetTriggered,
  isUnsubscribed,
  close,
  resetState,
  unsubscribe
} = useVueExitIntent(options);

isShowing: a reactive boolean ref that tracks whether the exit intent popup is currently visible.
isAllowedToGetTriggered: a reactive boolean ref that tracks whether the exit intent popup is allowed to trigger.
isUnsubscribed: a reactive boolean ref that tracks whether the user has unsubscribed from the exit intent popup.
close: a function that closes the exit intent popup and resets any related states (e.g. the isShowing ref).
resetState: a function that resets all state related to the exit intent popup (e.g. isShowing, isAllowedToGetTriggered, isUnsubscribed).
unsubscribe: a function that unsubscribes the user from the exit intent popup.

Options

KeyDefault ValueTypeRequired
repeatAfterDays7Numberfalse
scrollPercentageToTrigger0Numberfalse
delaySecondsAndTrigger0Numberfalse
triggerOnExitIntenttrueBooleanfalse
touchDeviceSensitivity15Numberfalse
scrollDebounceMillis300Numberfalse
triggerOnPageLoadfalseBooleanfalse
handleScrollBarsfalseBooleanfalse
LSItemKey'vue-exit-intent'Stringfalse

Options Description

  • repeatAfterDays
    After how many days you want the popup to get triggered again.
    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.
    Giving a zero, the popup will be shown only once! Until the localstrage of the user gets cleared/resets.
    Give 0 to disable.
    This one runs a CHECK before show.

  • scrollPercentageToTrigger
    A scroll percentage that if reached by the user, the pop-up will get triggered.
    Give 0 to disable.
    This one TRIGGERS the popup.

  • delaySecondsAndTrigger
    Trigger the pop-up after a short delay in seconds, once the page has loaded.
    Give 0 to disable.
    This one TRIGGERS the popup.

  • touchDeviceSensitivity
    On touch devices where there is no mouseleave event, the popup will get triggered on fast (touch)scroll up. The larger the number you will give, the more sesitive will be the pop-up on touch devices.
    Give 0 to disable.
    This one TRIGGERS the popup on touch devices.

  • triggerOnExitIntent
    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. If true, your modal pop-up is set to get triggered on user exit-intent.
    This one TRIGGERS the popup.

  • scrollDebounceMillis
    Time in milliseconds to debounce user's scrolling

  • triggerOnPageLoad
    Show your modal pop-up immediately When a user visits your page.

  • handleScrollBars
    Composable will handle the value of: document.body.style.overflowY.
    Will be eather auto (when isShowing is false), or hidden (when isShowing is true)

  • LSItemKey
    Key of Local Storage item. You can use a different key to show multiple pop-ups with different behaviour/content.

Contribute

Feel free to contribute, message me for your idea.

  • Write tests.
  • Report a bug.
  • Share this project.
  • Give a star if you like it.
  • Documentation

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Compile and Minify for Production

npm run build

Lint with ESLint

npm run lint

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Customize configuration

See Vite Configuration Reference.

License

The MIT License (MIT)

Copyright © 2022 nickap

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

Keywords

FAQs

Last updated on 10 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc