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

meta-viewport-shim

v0.3.0

Published

A viewport fix for Firefox OS TVs and other devices that don't support meta viewport

Downloads

6

Readme

meta-viewport-shim

A viewport fix for devices (including Firefox OS TVs) that don't support meta viewport.

The Problem

Example: You've coded your app to standard 1280x720 resolution for an HD television but you open the app on an Ultra HD TV and the app only appears to display on half of the television -- yikes! Ideally the following meta tag would direct the app to scale larger to device size:

<meta name="viewport" content="width=1280, initial-scale=1">

If the app renderer does not support meta viewport, however, your app will not scale.

The Optimal Solution

The optimal solution to this problem is to not use this shim but instead use @media queries to detect a given screen size and make adjustments to it. For example, the following CSS media query could target Firefox OS Ultra HD TVs:

@media (max-width:1920px) and (max-height:1080px) {
  #app-wrapper {
    width: 1920px;
    height: 1080px;
  }

  /*
    Adjust any other important dimensions for other elements here
  */
}

This solution will require more work but a more reliable, visually appealing display.

The Shim

meta-viewport-shim aims to simulate meta viewport support by gathering screen dimensions, analyzing the app's wrapping node dimensions, and using CSS Transforms to scale the app to full screen dimensions.

Implementing the Shim

Add meta-viewport-shim.js to your page via a script tag:

<script src="meta-viewport-shim.js"></script>

Call the global metaViewportShim function, providing it the DOM node that "wraps" the app:

metaViewportShim.shim(document.querySelector('#app-wrapper'));

To see a report of dimensions and applied scale (for use in debugging only), send true as a second argument:

metaViewportShim.shim(document.querySelector('#app-wrapper'), true);

This utility uses a whitelist of known user agents that don't support meta viewport so as not to disturb an app when it shouldn't:

userAgents: [
  'Mozilla/5.0 (FreeBSD; Viera; rv:34.0) Gecko/20100101 Firefox/34.0',
  'Mozilla/5.0 (FreeBSD; Viera; rv:44.0) Gecko/20100101 Firefox/44.0'
],

If you'd like to apply meta viewport in all cases, simply do the following before calling shim():

metaViewportShim.push(navigator.userAgent);
metaViewportShim.shim(document.querySelector('#app-wrapper'));

Notes

  • Some apps have found success with using the CSS zoom property. The zoom property is not supported by Firefox or Firefox OS.

  • CSS transforms may slightly impact performance of app or game

What's in this repo?

Inside this repo is the meta-viewport-shim.js file you'll need to make this work, a test page, and an app manifest for testing on various screens and devices.