New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-longpressable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-longpressable

Long-press component for React that uses pointer events.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
460
decreased by-62.9%
Maintainers
1
Weekly downloads
 
Created
Source

React LongPressable

npm

Long-press wrapper for React that uses pointer events. Supports normal clicks as well.

Pointer events are hardware agnostic, meaning that they can be triggered by a mouse, a pen/stylus, or touch. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events

Install

npm install --save react-longpressable

Props

  • onShortPress(event) (function): callback for normal clicks.
  • onLongPress(event) (function): callback for long presses.
  • longPressTime (number, default 500): duration of a long press in milliseconds.
  • dragThreshold (number, default 5): distance in pixels that the mouse is allowed to move while clicking without canceling the long press.
  • primaryMouseButtonOnly (boolean, default true): whether long presses are only triggered by the left mouse button.

Example

import React from 'react';
import LongPressable from 'react-longpressable';

export default class Example extends React.PureComponent {

  onLongPress = (e) => {
    console.log('Long pressed.');
  }

  onShortPress = (e) => {
    console.log('Short pressed.');
  }

  render() {
    return (
      <LongPressable
        onShortPress={this.onShortPress}
        onLongPress={this.onLongPress}
        longPressTime={700}>
        <button>Press Me!</button>
      </LongPressable>
    );
  }

}

Keywords

FAQs

Package last updated on 09 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc