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

responsive-mq

v1.6.0

Published

Responsive MQ has been designed to enable you to attach JavaScript functions to media queries so you can have viewport specific code executing within your app to partner up with your responsive CSS.

Downloads

19

Readme

responsive-mq.js

What is it for?

Responsive MQ has been designed to enable you to attach JavaScript functions to media queries, so you can have viewport specific code executing within your app to partner up with your responsive CSS. It does this by registering named elements of markup which can then be checked on resize to determine what the current viewport is. This is handled by the responsive-mq.js 'registerBreakpoint()' and 'activate()' functions.

How do I get set up?

In order to make use of Responsive MQ, simply add a reference to the javascript file in your page or using your favourite script loader. In the attached sample HTML file the references are added manually toward the end of the body tag.

<script src="jquery.min.js"></script>
<script src="responsive-mq.min.js"></script>

As of v 1.2.2 it now supports AMD - You can use it with RequireJS like this...

define(['responsive-mq', 'jquery'],
    function(ResponsiveMQ) {
		ResponsiveMQ.registerBreakpoint('mobile', '', function () {
	    $('#display').text('This is mobile viewport');
	});
    });

This will affect where Responsive MQ is placed. If you are using traditional methodology then it will be attached to the jQuery object. If you are using RequireJS then it will be returned by itself.

Responsive MQ is dependent on jQuery. It's been tested with 1.11 but should be compatible with all versions of jQuery - Feel free to raise a bug if you experience any issues with specific versions. The reason for this is jQuery's comparatively faster speed when setting up resize event responses.

How do I use it?

Using responsive-mq is a two-step process. Firstly you need to register a breakpoint against a matching function and an optional function to execute when the breakpoint no longer matches the media query...

$.responsiveMQ.registerBreakpoint('mobile', '', function () {
    $('#display').text('This is mobile viewport');
});

or...

$.responsiveMQ.registerBreakpoint('mobile', '', function () {
    $('#display').text('This is mobile viewport');
    $('#notMobile').hide();
}, function() {
    $('#notMobile').show();
});

Once you have registered all of your breakpoint functions you can activate responsive-mq as follows...

$.responsiveMQ.activate();

This needs to be a multistep process so that it can render all the required markup and style blocks.

Limitations

The intention of responsive-mq is purely to handle identification of a single valid viewport. To this end only one of the specified registered breakpoints will be active at any one time. Trying to use multiple overlapping media queries will have unpredictable results.

jQuery

Use v1.2.x for jQuery 1.x Use v1.3.x for jQuery 2.x Use v1.4.x for jQuery 3.x

The Ministry of Technology Open Source Products

Welcome to The Ministry of Technology open source products. All open source Ministry of Technology products are distributed under the MIT License for maximum re-usability. Our other open source repositories can be found here...

Where can I get it?

You can download the javascript file (dev or minified version) from the downloads page here and add it to your website manually, or you can use any of the following package managers...

Contribution guidelines

If you would like to contribute to the project, please contact me.

The source code can be used in a simple text editor or within Visual Studio using Node.js Tools for Visual Studio.

Who do I talk to?