npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

egress-intent

v1.0.1

Published

> OuiBounce originally created by [Carl Sednaoui](http://carlsednaoui.com/about) from [MailCharts](http://www.mailcharts.com/). Ported to TypeScript and adapted into EgressIntent by [Sean Bennett](https://swbennett.com).

Downloads

35

Readme

EgressIntent

OuiBounce originally created by Carl Sednaoui from MailCharts. Ported to TypeScript and adapted into EgressIntent by Sean Bennett.

EgressIntent offers a simple interface to execute code as the user's cursor exits a given area, with the added functionality of limiting the number of times this can occur over a given period of time by setting a cookie.

An adaptation of the OuiBounce library from Carl Sednaoui and other contributors, it has diverged from the original library:

  • EgressIntent eschews the original library's style attribute modification of a given "modal" element on exit trigger, instead leaving the exact code to execute up to the developer.

Installation

Simply run npm install egress-intent.

Usage

Basic Usage:

EgressIntent is intended for use with a module bundler. For a project with ES6 modules enabled, simply:

import EgressIntent from 'egress-intent';

const trigger = new EgressIntent({
    callback: () => { console.log('Fired'); }
});

If using another module loader:

const EgressIntent = require('egress-intent').default;

Methods

The trigger can be manually fired:

trigger.fire();

Or disabled:

trigger.disable();

Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | aggressive | boolean | false | Ignores whether a cookie has been set and always fires on exit. | | timer | number | 1000 | The number of milliseconds after which to attach handlers. Reduces false positives. | | delay | number | 0 | The number of milliseconds after which the user has exited the callback should trigger. Setting this allows the user to briefly exit and then return without triggering. | | cookieExpire | number | 1 | The number of days after which the cookie should expire and trigger the code again for the user. | | cookieDomain | string | '' | If you need a cookie to work also in your subdomain (like blog.example.com and example.com), then set a cookieDomain such as .example.com (notice the dot in front). | | cookieName | string | 'triggeredEI' | If desired, override the default cookie name. | | sitewide | boolean | false | If true, the cookie will apply to every page of the site rather than only that which the user triggered the code to be fired. | | target | HTMLElement | document.documentElement | The element that defines the boundaries of the exit. | | sensitivity | number | 20 | How far the mouse must be from the edge. | | directions | string or string[] | ['top', 'right', 'bottom', 'left'] | The exit directions that will trigger the callback. |

When manually calling the disable() method on the class, custom cookie options (cookieExpire, cookieDomain, cookieName, and sitewide) can be specified that override those set when the class was instantiated:

trigger.disable({
    cookieExpire: 10
});