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

checkmq

v2.0.0

Published

Media Queries in JavaScript

Downloads

11

Readme

checkMQ

Build Status Code Climate npm Gitter

checkMQ utilises matchMedia event listeners to provide you with access to media queries in JavaScript as you would in CSS.

Usage

Include checkMQ in your project. You can either use the script in the traditional method like so:

<script src="checkMQ.min.js"></script>

or use requireJS, webpack etc like so:

var checkMQ = require('checkmq.min.js');

If using NPM to manage dependencies you can do the following:

npm install checkmq

Each function that needs access the defined media queries should have theMQ passed through as a parameter. The value of theMQ will change when it matches one of the predefined media queries.

var testFunction = function (theMQ) {

  if (theMQ === 'mqCore') {
    console.log('mqCore');
  } else if (theMQ === 'mq600') {
    console.log('mq600');
  } else if (theMQ === 'mq768') {
    console.log('mq768');
  } else if (theMQ === 'mq960') {
    console.log('mq960');
  } else if(theMQ === 'mq1200') {
    console.log('mq1200');
  }

};

var anotherTestFunction = function (theMQ) {

  if (theMQ === 'mqCore') {
    alert('this is a small screen device');
  }

};

Each function that requires access to theMQ must be passed the addFunctions method which adds the appropraite matchMedia listeners. It's important that this is the last method called.

checkMQ.addFunctions([
  testFunction,
  anotherTestFunction
]);

Browser support

  • Internet Explorer 10+
  • Firefox 10+
  • Chrome 9+
  • Safari 5.1+
  • Opera 12.1+

For IE 9 support you can use Weblinc's Media.match Polyfill.

TODO

  • Improve the method of definining media queries so they can become dynamic

Changelog

  • 21/12/15: 2.0.0 - Major rewrite using ES6.
  • 01/07/15: 1.3.1 - Tidied up the code and fixed the timing issue in <= IE10
  • 18/06/15: 1.2.0 - Converting to an Node.js module and updating README to include instructions for this
  • 26/03/15: 1.1.1 - Updated README to be more clear on how it works
  • 18/03/15: 1.1.0 - Fixing missing bracket on doc ready function and bumping version number to account for rewritten code
  • 18/03/15: 1.0.6 – Removing forEach method and using a 'for' loop as it's replacement for wider browser support
  • 16/03/15: 1.0.5 – Updating README
  • 13/03/15: 1.0.4 – Fixing broken module code
  • 13/03/15: 1.0.3 – Fixing package.json
  • 13/03/15: 1.0.2 – Code tidy up to fix Travis issues
  • 13/03/15: 1.0.0 – First major release: registered as a Bower plugin.