Socket
Socket
Sign inDemoInstall

drag-event-service

Package Overview
Dependencies
3
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    drag-event-service

Register both mouse and touch event. ```js // mapping const events = { start: ['mousedown', 'touchstart'], move: ['mousemove', 'touchmove'], end: ['mouseup', 'touchend'], } ``` # install ```sh npm install drag-event-service ``` # usage & api ```js i


Version published
Weekly downloads
6.4K
decreased by-21.22%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

drag-event-service

Register both mouse and touch event.

// mapping
const events = {
  start: ['mousedown', 'touchstart'],
  move: ['mousemove', 'touchmove'],
  end: ['mouseup', 'touchend'],
}

install

npm install drag-event-service

usage & api

import DragEventService from 'drag-event-service'
DragEventService.on(el, name, handler, {args, mouseArgs, touchArgs})

on(el, name, handler, {args, mouseArgs, touchArgs}); off(el, name, handler, {args, mouseArgs, touchArgs})

  • args, mouseArgs and touchArgs should be Array
  • The args will pass to addEventListener.
  • mouseArgs will pass to mouse event.
  • touchArgs will pass to touch event.
  • handler(event, currentPosition). The second argument of handler is current position({x, y}).

example

// 1
DragEventService.on(document, 'start', (e, mouse) => ..., {touchArgs: [{passive: false}]})
DragEventService.on(document, 'move', (e, mouse) => ..., {touchArgs: [{passive: false}]})
DragEventService.on(document, 'end', (e, mouse) => ..., {touchArgs: [{passive: false}]})
// 2
const handler = (e, mouse) => ...
DragEventService.on(document, 'start', handler)
DragEventService.off(document, 'start', handler)

FAQs

Last updated on 29 Dec 2019

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