Socket
Socket
Sign inDemoInstall

@okiba/drag-emitter

Package Overview
Dependencies
3
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @okiba/drag-emitter

Unified drag events emitter for mouse and touch


Version published
Weekly downloads
0
Maintainers
3
Created
Weekly downloads
 

Readme

Source

Okiba / DragEmitter

Emits drag events for all common pointers kinds (touch & mouse)

__

Installation

npm i --save @okiba/drag-emitter

Or import it directly in the browser

<script type="module" src="https://unpkg.com/@okiba/drag-emitter/index.js"></script>

Usage

import DragEmitter from '@okiba/drag-emitter'
Untranspiled code 🛑

Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:

{
  test: /\.js$/,
  exclude: /node_modules\/(?!(@okiba)\/).*/,
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env']
    }
  }
}

constructor(el)

import {DragEmitter} from '@okiba/drag-emitter'
import {qs} from '@okiba/dom'

const dragEmitter = new DragEmitter(qs('.container'))
dragEmitter.on(
  'drag',
  ({deltaX, clientX, deltaY, clientY}) => {
    console.log(deltaX, clientX, deltaY, clientY)
  }
Arguments
+ el: Element

Element whose surface is used for drag events

destroy()

Unbinds events from the element and deletes the reference. To be called when the instance is not needed anymore for cleanup.

Keywords

FAQs

Last updated on 26 May 2020

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