Skip to content

Latest commit

 

History

History
113 lines (82 loc) · 1.85 KB

README.md

File metadata and controls

113 lines (82 loc) · 1.85 KB

User Intent (Exit Intent) 🚀

Detect user intent and trigger a callback.

Usage 👨‍💻

Idleness

const options = {
    mode: 'idle',
    events: ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart'],
    delay: 10000,
    multiple: false,
};

const cb = (mode, opts) => {
    console.log(`Callback -> mode is "${mode}" with options of "${JSON.stringify(opts)}"`);
};

new UserIntent(cb, options);

Scroll

const options = {
    mode: 'scroll',
    percentDown: 50,
    percentUp: 0,
    offsetTop: 0,
    offsetBottom: 0,
};

const cb = (mode, opts) => {
    console.log(`Callback -> mode is "${mode}" with options of "${JSON.stringify(opts)}"`);
};

new UserIntent(cb, options);

Target Element

const options = {
    mode: 'target',
    target: '',
    offsetTop: 0,
    offsetBottom: 0,
    multiple: false,
};

const cb = (mode, opts) => {
    console.log(`Callback -> mode is "${mode}" with options of "${JSON.stringify(opts)}"`);
};

new UserIntent(cb, options);

Window Focus

const options = {
    mode: 'focus',
    multiple: false,
};

const cb = (mode, opts) => {
    console.log(`Callback -> mode is "${mode}" with options of "${JSON.stringify(opts)}"`);
};

new UserIntent(cb, options);

Window Out

const options = {
    mode: 'out',
    multiple: false,
};

const cb = (mode, opts) => {
    console.log(`Callback -> mode is "${mode}" with options of "${JSON.stringify(opts)}"`);
};

new UserIntent(cb, options);

How to launch the project 🏁

Install Node.js and then open the Terminal/CMD and navigate to the project's folder. Run the following command:

npm install

Development evnironment

npm start

Production build

npm run build

Builds the app for production to the build folder.\

Stay safe 😷