JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 223
  • Score
    100M100P100Q71552F
  • License MIT

Javascript: create click event for both mouse and touch

Package Exports

  • clicked

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clicked) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

clicked

Create click event for both mouse and touch

rationale

To create a simple way to handle mouse and touch click events without any external dependencies.

example

import clicked from 'clicked';

function handleClick()
{
    console.log('I was clicked.');
}

const div = document.getElementById('clickme');
clicked(div, handleClick, {thresshold: 15});

API

export default function clicked(element, handler, options)

  • {htmlElement} element to listen for mouse and touch events
  • {function} handler to call after a click
  • {object} [options]
  • {number} [options.threshhold] maximum number of pixels that the touch may move before cancelling click