Socket
Socket
Sign inDemoInstall

drag-resistant-click-listener

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    drag-resistant-click-listener

A click listener that is resistant to mouse drag movements


Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

drag-resistant-click-listener

Summary

This package provides the ability to add a click listener to an element that will only call the provided click event handler when the mouse has not been dragged far from the initial mouse-down position.

This is useful, for example, when you have element(s) that you want to have both on-click and on-drag behaviour. A real-world example of this is when you want to have an element that will do something on-click (e.g. navigate the user), but you also want the text inside the element to be selectable, or perhaps you want the element to be draggable to be moved around, etc.

Usage

npm install drag-resistant-click-listener

import { addDragResistantClickListener } from 'drag-resistant-click-listener'

const element = document.createElement('div')
addDragResistantClickListener({
  element,
  onClick: () => console.log('element was clicked!'),
  onCancel: () => console.log('element click was cancelled. We are now dragging!')
})

FAQs

Last updated on 30 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc