@daign/handle
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

daign-handle

CI Coverage NPM package

Define drag actions for DOM elements.

Installation

npm install @daign/handle --save

Usage example

import { Handle } from '@daign/handle';

// Create the node which will initiate the drag, or reference it from your HTML.
const node = document.createElement( 'div' );

// Create the Handle.
const handle = new Handle();
handle.setStartNode( node );

// Callback to execute when drag starts.
handle.beginning = (): boolean => {
  // Get the coordinates of the start event.
  console.log( handle.start );

  // Return value determines whether to continue the drag.
  return true;
};

// Callback to execute during the drag.
handle.continuing = (): void => {
  // Get the coordinates of the events during the drag.
  console.log( handle.temp );

  // Get the difference between start and temp position.
  console.log( handle.delta );
};

// Callback to execute when the drag has ended.
handle.ending = (): void => {};

Scripts

# Build
npm run build

# Run lint analysis
npm run lint

# Run unit tests with code coverage
npm run test

# Get a full lcov report
npm run coverage

Readme

Keywords

Package Sidebar

Install

npm i @daign/handle

Weekly Downloads

249

Version

1.1.1

License

MIT

Unpacked Size

51.4 kB

Total Files

17

Last publish

Collaborators

  • daign