New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

poniter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poniter

A pointer event router with helper functions for positioning.

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
9
80%
Maintainers
1
Weekly downloads
 
Created
Source

poniter

Poniter is a UI library that implements lightweight, emphemeral routers for pointers (mouse, touch, and stylus events).

Requirements

Poniter expects the following features in the environment, which will need to be polyfilled:

  • ES6 Maps
  • Pointer Events

Also note that, to get pointer events for touches, you will need to set "touch-action" to "none" (either as a style or as an attribute, depending on the way your polyfill works) on <html>, <body>, or any element you want touch events to start from.

Listening

To listen for poniter-enhanced pointer events, call poniter.listen with the element you wish to listen to, then call ".on" methods for respective pointer events:

/*global poniter*/
poniter.listen(document.getElementById('example'))
  .on('enter', function(evt) {
    console.log('new pointer over example element');
  })
  .on('down', function(evt) {
    console.log('example element tapped');
  })

Any event can also listen to further events from the given pointer by using the pon method of the event (you may wish to combine this with setPointerCapture) - each pon call returns the original event, so multiple pon calls may be chained:

poniter.listen(document.getElementById('example'))
  .on('down', function(evt) {
    var downtime = Date.now();
    evt.target.setPointerCapture(evt.pointerId);
    evt.pon('up', function(evt) {
      var duration = (Date.now() - downtime) / 1000;
      console.log('Pointer dropped after ' + duration + ' seconds');
    }).pon('cancel',function(evt) {
      var duration = (Date.now() - downtime) / 1000;
      console.log('Pointer canceled after ' + duration + ' seconds');
    });
  });

License in Three Lines (LITL)

Copyright 2015 Stuart P. Bentley.
This work may be used freely as long as this notice is included.
The work is provided "as is" without warranty, express or implied.

Keywords

pointer

FAQs

Package last updated on 08 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts