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

minsky-mq-manager

v1.1.0

Published

Listen to media changes in the viewport with ease

Downloads

8

Readme

MQManager

Listen to media changes in the viewport with ease.

Manages events dispatched by watchMedia, binds listeners to the right scope and dispatches only the media query events that were added by the codebase.

Class type: Manager

Dependencies

  • EventDispatcher 1.0.0
  • Ticker 1.0.0

Getting started

Class can both be constructed directly or extended to provide classes with media query management.

const manager = new MQManager({
    queries: [
        { name: 'ready',            query: '(min-width: 0rem)' },
        { name: 'mobileNavInit',    query: '(max-width: 46.875rem)' },
        { name: 'mobileNavDestroy', query: '(min-width: 46.875rem)' },
    ],
});


// add listener
manager.on('biggest', (e) => {
	console.log('biggest media query event')
})

Constructor Parameters

Args

Type: Object Default: {}

Config options that will be used when instance is created

ObjectName

Type: String Default: 'MQManager'

Object name that will be used as recognisable identifier and as prefix in logs


Interface

Options

queries

Type: Array Default: []

Query definitions it has to listen to. Each query definition needs 2 properties

  • Name => will be the name of the event
  • Mq => the media query it has to listen to, like you’d define it in css

Properties

mqs

Type: Array Default: []

Collection of added query definitions with their bound listeners.

Methods

constructor

Parameters: Args:object, objectName:String Return: Self

Creates the class, sets the element and applies the given state definitions if any. Adds all given queries automatically.

add

Parameters: mq:String, name:String or mqs:Array Return: undefined

Adds a query definition to the manager so it will dispatch events when

get

Parameters: identifier:String Return: Array

Get a query definitions that match a given string. It will check both the name and the query.

remove

Parameters: identifier:String Return: undefined

Remove a query definition based on a string that matches the name or the query

destroy

Parameters: none Return: undefined

Removes the listeners & destroys the instance.

Events

[Name of a definition]

Parameters: Event

Dispatches an event with extra information in the data object.


To Do

  • Make mqs property private