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

orient-express

v0.1.3

Published

Javascript page orientation library. Its name is a terrible pun.

Downloads

1

Readme

Orient Express

Load this and it will quickly tell you the orientation of your page. It will let you know if it's Landscape, Portrait, or Square.

I know that there are other libraries out there that do this, and probably do it just as well or maybe even better.

Quickstart

You basically need to include the /dist/orientexpress.min.js file on your page, and then invoke a new OrientExpress object.

var ox = new OrientExpress();

This object contains the following properties:

  • .width - the width of the window
  • .height - the height of the window
  • .landscape - returns true if it's landscape, false if it isn't *
  • .portrait - returns true if it's portrait, false if it isn't *
  • .orientation - returns landscape, portrait, or square.

*Please note - .landscape and .portrait will return false if the page is square.

Options

By default, the orientation values will be updated automatically when the page is loaded and whenever the window size changes. If you don't want it to refresh when the page is resized, pass false when invoking the new object.

var ox = new OrientExpress(false);

API

While not strictly necessary, the library also contains some API methods.

These can be called using the following:

var ox = new OrientExpress();
var orientation = ox.getOrientation();

.getOrientation();

Returns landscape, portrait, or square.

.isLandscape();

Returns true if it's landscape, false if it isn't.

.isPortrait();

Returns true if it's portrait, false if it isn't.

Tests

This uses QUnit for testing. The tests can be checked by running ./test/index.html. These are not currently tested during the build process as the browser resize testing requires further input to work with the Phantom library.

About

I built this module because I've copied and pasted the same code into three or four projects and thought it would make sense to have a single, usable library that I could just import when I needed it.

Originally I was going to call this "Yogi Bearings", but I realised that would cause confusion because while "bearings" is a synonym of "orientation", it doesn't really mean the same thing. And there are already npm modules called "yogi", so there could be some confusion there too. (There are also some modules called both "orient" and "express", but I think this is OK).