Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

click-and-hold

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

click-and-hold

[![Build Status](https://travis-ci.com/Duder-onomy/click-and-hold.svg?branch=master)](https://travis-ci.com/Duder-onomy/click-and-hold)

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
211
-27.74%
Maintainers
1
Weekly downloads
 
Created
Source

Click And Hold

Build Status

Will fire a handler throttled by an interval, continuously while user presses on element.

Supports touch.

Zero dependencies.

How to use:

Important to note: If your handler relies on scope, ensure it is called with the correct scope by binding the scope directly, or using the closure.

import clickAndHold from 'click-and-hold';

clickAndHold.register(element, handler.bind(theScopeYouWant), interval);

clickAndHold.unregister(element);

How it works:

When the element is first interacted with (mousedown, touchstart), we start a loop that will continuously try and call a passed handler on a passed interval. To avoid complexity, we store the interval and subsequent handlers on the element itself. Its only 50 something lines. Scope it.

Install:

npm install --save-dev click-and-hold

Upgrading

From 1.X.X -> 2.X.X, We are now using es6 module imports instead of common.js. Thinks like webpack/browserify/etc should be able to hang either way.

I am not trying to camp names on NPM, so if someone else wants this name just let me know and I will gladly take my repo down.

FAQs

Package last updated on 20 Mar 2020

Did you know?

Socket

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