1.0.1 • Published 6 years ago

preact-long-press-event v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

preact-long-press-event: onLongPress for Preact

onLongPress is a CustomEvent generated using native Event.

Inspired by long-press

Usage

npm i -S preact-long-press-event

// in your index.js

import injectLongPressEvent from 'preact-long-press-event';

/**
 * @params {object} options
 * 
 * Options can be an object containing duration property
 * 
 * {
 *   duration: <duration_in_milliseconds>
 * }
 * 
 * The default delay duration is 1500
 */
injectLongPressEvent();


// in your component

class MyComponent extends Component {
  
  longPress(event) {
    // longPress event handller
  }

	render() {
		return (
			<div class="app">
				<button onLongPress={this.longPress}>Long Press Me!</button>
			</div>
		);
	}
}

Options

  • duration a delay duration for long press in milliseconds default is 1500

Example

// Set the long press duration to 2 seconds
injectLongPressEvent({
  duration: 2000
});

1.0.1

6 years ago

1.0.0

6 years ago