exit-intent-quattro
v1.4.0
Published
Exit intent detection library - detects all 4 edges.
Downloads
459
Readme
Exit Intent Quattro
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
, andleft
- string with possible values:
position
- object with
x
andy
numeric properties indicating the position at which exit intent was detected
- object with
License
MIT
originally based on https://github.com/richriscunha/Exitent