npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dor

v0.0.2

Published

dOr

Downloads

2

Readme

dOr:

dOr is a usability wrapper for the HTML5 deviceOrientation API. Its main features are as follows:

  • dOr Cleans up noise from imprecise readings, by taking the average of a 'window' of readings
  • dOr Provides a convenient interface for:
    • Accessing device orientation data, with readings stored in private data members hidden from the rest of your application
    • Throttling potentially expensive callback functions, that are frequently invoked on deviceOrientation events
    • Customizing the above functionaly. namely, average 'window' size, and throttle intervals

Usage

Use npm and browserify. (to be completed)

Instantiate dOr as follows:

  //instantiates a handler object, 10 will be the 'window' size, instead of a default of 5
  let dOr_handler = dOr(10); 

  //attaches a listener, with no throttling. this callback will respond to all deviceOrientation events
  dOr_handler.onTilt(function(dOr_data){…});

  //attaches a listener, throttling the callback at 500ms
  dOr_handler.onTilt(function(dOr_data){…}, 500);

  //returns the most recent dOr_data object (see below)
  dOr_handler.getMostRecentEvent();

The dOr object will add a deviceOrientation listener to DOM_document. If the corresponding optional paramater was passed, the callback function will be throttled.

dOr_data Specification:

dOr_data, the object passed to all callbacks, has the following properties:

event : this object is the original deviceOrientation event, with alpha, beta, and gamma properties.
x : a number from [-1, 1] mapping a degree of tilt to a gamma reading from [-90, 90]. x corresponds to the x-axis of a cartesian plane.
y : same as x, but for the y-axis. [-1, 1] is mapped to beta values of [-90, 90]. Note that beta values are in [-180, 180]: in this case dOr will assume anything above a 90-degree tilt is 'maximum tilt', and will return a value of -1 or 1.

Browser Differences:

dOr is tested in Chrome xxx.

Note that event.alpha (or dOr_data.alpha) behaves differently in Mobile Safari, as explained in this HTML5Rocks article.

As mentioned earlier, alpha, beta and gamma are determined based on the position the device is with the local earth frame. For most browsers, alpha returns the compass heading, so when the device is pointed north, alpha is zero. With Mobile Safari, alpha is based on the direction the device was pointing when device orientation was first requested. The compass heading is available in the webkitCompassHeading parameter.

Projects using dOr:

  1. ThePullUpGame (an early version of dOr)