![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
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 readingsdOr
Provides a convenient interface for:
deviceOrientation
eventsUse 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 originaldeviceOrientation
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
or1
.
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.
FAQs
dOr
The npm package dor receives a total of 1 weekly downloads. As such, dor popularity was classified as not popular.
We found that dor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.