1.1.1 • Published 3 months ago

@daign/handle v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
3 months ago

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
1.1.1

3 months ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.10

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

4 years ago

1.0.0

5 years ago