0.0.31 • Published 3 years ago

@bivarcs/mt-event v0.0.31

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

mt-event

npm.io npm.io npm.io

A minimal function to get common values from mouse and touch events.

Demo

https://bivarcs.github.io/mt-event/demo/

Installation

Package Manager

npm: npm i @bivarcs/emitter
yarn: yarn add @bivarcs/emitter

CDN

<script src="https://unpkg.com/@bivarcs/mt-event/dist/js/parseMTEvent.min.js"></script>

Document

Usage

addEventListener((event: MouseEvent | TouchEvent) => {
  const parsedEvent = parseMTEvent(event);

  console.log(parsedEvent);
});

/*
You can get.
{
  clientX: 0,
  clientY: 0,
  event: Object,  // original event
  pageX: 0,
  pageY: 0,
  type: 1,  // 1=mouse, 2=touch
  screenX: 0,
  screenY: 0,
}
*/

Usually used like this:

import { parse as parseMTEvent } from "src/js/parse"

addEventListener((event: MouseEvent | TouchEvent) => {
  const parsedEvent = parseMTEvent(event);
  console.log(parsedEvent);
});

License

MTEvent is available under the MIT license.

The license is MIT for convenience. Anyone can write the code, so write it yourself. (In that case, the license is free.)

0.0.31

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago