Skip to content

johnnyoshika/exit-intent-quattro

 
 

Repository files navigation

Exit Intent Quattro

version MIT License Standard Standard Version Size Size gzip

Exit Intent detection library based on Dan Hayden's original version. This library builds on top of the original version by adding edge detection on all 4 edges of the viewport instead of just the top.

Usage

import exitIntent from 'exit-intent-quattro';

// Initialise
const removeExitIntent = exitIntent({
  edges: {
    top: true,
    right: true,
    bottom: true,
    left: true,
  },
  threshold: 20,
  maxDisplays: 2,
  eventThrottle: 100,
  onExitIntent: ({side, position: {x, y}}) => {
    console.log(`exit-intent triggered on ${side} side at position ${x}, ${y}`);
  },
});

// Destroy
removeExitIntent();

Options

edges (default {top: true, right: false, bottom: false, left: false})
edges of the viewport that triggers exit intent.

threshold (default 20)
maximum distance in pixels from the top of the page to trigger.

maxDisplays (default 1)
maximum number of times to trigger.

eventThrottle (default 200)
event throttle in milliseconds.

onExitIntent (default no-op function)
function to call when an exit intent has been detected. An object will be passed in with these properties (see example above):

  • side
    • string with possible values: top, right, bottom, and left
  • position
    • object with x and y numeric properties indicating the position at which exit intent was detected

License

MIT

originally based on https://github.com/richriscunha/Exitent

About

Exit Intent detection library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%