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

bootstrap-breakpoints

v1.0.0

Published

Easy way to determine current bootstrap media query breakpoint

Downloads

1,421

Readme

Boostrap Breakpoints

Build Status Code Climate Test Coverage

Tiny script to enable easier checks for current responsive breakpoint. Assumes you are using bootstrap, but can potentially work with other custom breakpoints.

Usage

Put the script somewhere in the html as you usually do. For now the script depends on jQuery and works in IE9+.

Breakpoint.init();

if (Breakpoint.is('xs')) {
    //do mobile stuff
}

if (Breakpoint.is('sm')) {
    //do tablet stuff
}

$(window).on('change:breakpoint', function (e, current, previous) {
    console.log('previous breakpoint was', previous);
    console.log('current breakpoint is', current);
});

//etc

If you need to customize breakpoint values, you do

Breakpoint.init({
    xs: {
        min: 0,
        max: 499
    },
    sm: {
        min: 500,
        max: 1000
    }
    //etc
});

How it works

On init script registers an event handler on window resize where it just checks window.width and if correct breakpoint is found it sets the value internally as well as triggering 'change:breakpoint' event on window. You may want to throttle the event handler, but it's not yet possible without modifying source code. Also, keep in mind that it is assumed that breakpoints you provide are mutually exclusive, otherwise detected current breakpoint may be not the one you expect.

API

.is(breakpoint)

Returns true if passed value is a correct breakpoint.

.current()

Returns string representing current breakpoint (xs, sm, etc).

.getBreakpoints()

Get all the breakpoints values.

.init(breakpoints)

Initializes the script. Without calling this first - won't work.

.destroy()

Removes resize watcher.

Demo

http://vxsx.github.io/bootstrap-breakpoints/

Contributing

Make PR, write your stuff, don't forget tests.