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

orientationchangeend

v1.1.2

Published

The orientationchangeend event is fired when the orientation of the device has changed and the associated rotation animation has been complete.

Downloads

17,282

Readme

orientationchangeend

NPM version Bower version

The orientationchangeend event is fired when the orientation of the device has changed and the associated rotation animation has been complete. orientationchangeend enables you to capture dimensions of the element in the state after the rotation change.

The Underlying Implementation

There is no way to capture the end of the orientation change event because handling of the orientation change varies from browser to browser. Drawing a balance between the most reliable and the fastest way to detect the end of orientation change requires racing interval and timeout.

A listener is attached to the orientationchange. Invoking the listener starts an interval. The interval is tracking the state of window.innerWidth and window.innerHeight. The orientationchangeend event is fired when config.noChangeCountToEnd number of consequent iterations do not detect a value mutation or after config.noEndTimeout milliseconds, whichever happens first.

If there is a series of orientationchange events fired one after another, where n event orientationchangeend event has not been fired before the n+2 orientationchange, then orientationchangeend will fire only for the last orientationchange event in the series.

Usage

var config = {},
    OCE;

// Start tracking the orientation change.
OCE = gajus.orientationchangeend(config);

// Attach event listener to the "orientationchangeend" event.
OCE.on('orientationchangeend', function () {
    // The orientation have changed.
});

To make the orientationchangeend event available to the window, re-emit the event using a custom event:

var orientationchangeend;

// Make sure that you are not adding event emitter more than once.
if ('onorientationchangeend' in window) {
    window.onorientationchangeend = true;

    orientationchangeend = new CustomEvent('orientationchangeend');

    OCE.on('orientationchangeend', function () {
        window.dispatchEvent(orientationchangeend);
    })
}

// Attach a listener to the "orientationchangeend" event.
window.addEventListener('orientationchangeend', function () {
    console.log('The orientation of the device is now ' + window.orientation);
});

Configuration

| Name | Value | Default | | --- | --- | --- | | noChangeCountToEnd | Number of iterations the subject of interval inspection must not mutate to fire orientationchangeend. | 100 | | noEndTimeout | Number of milliseconds after which fire the orientationchangeend if interval inspection did not do it before. | 1000 | | debug | Enables logging of the events | false |

All of the configuration parameters are optional.

Download

Using Bower:

bower install orientationchangeend

Using NPM:

npm install orientationchangeend

The old-fashioned way, download either of the following files:

  • https://raw.githubusercontent.com/gajus/orientationchangeend/master/dist/orientationchangeend.js
  • https://raw.githubusercontent.com/gajus/orientationchangeend/master/dist/orientationchangeend.min.js