GithubHelp home page GithubHelp logo

vishwasjois / enquire.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wickynilliams/enquire.js

0.0 1.0 0.0 1.18 MB

Awesome Media Queries in JavaScript

Home Page: http://wicky.nillia.ms/enquire.js/

License: MIT License

JavaScript 90.36% CSS 6.27% HTML 3.37%

enquire.js's Introduction

#enquire.js - Awesome Media Queries in JavaScript

Build Status

enquire.js is a lightweight, pure javascript library (with no dependencies) for programmatically responding to media queries.

##Getting enquire.js

###Download

Get the latest build, ready to go:

###Install via Bower

To install via the bower package repository, enter the following at the command line:

bower install enquire

Easy as that :-)

###Build From Source

If you want build from source (and run all unit tests etc):

git clone git://github.com/WickyNilliams/enquire.js.git
cd enquire.js
npm install
grunt

Booya!

##Quick Start

The main method you will be dealing with is register. It's basic signature is as follows:

enquire.register(query /* string */, handler /* object || array  || function */);

query is the CSS media query you wish to respond to, and handler is an object containing any logic to handle the query. An example of usage is as follows:

enquire.register("screen and (max-width:1000px)", {

    match : function() {},      // OPTIONAL
                                // If supplied, triggered when the media query transitions 
                                // *from an unmatched to a matched state*

    unmatch : function() {},    // OPTIONAL
                                // If supplied, triggered when the media query transitions 
                                // *from a matched state to an unmatched state*.
                                // Also may be called when handler is unregistered (if destroy is not available)

    setup : function() {},      // OPTIONAL
                                // If supplied, triggered once immediately upon registration of the handler

    destroy : function() {},    // OPTIONAL
                                // If supplied, triggered when handler is unregistered. Place cleanup code here

    deferSetup : true           // OPTIONAL, defaults to false
                                // If set to true, defers execution the setup function 
                                // until the media query is first matched. still triggered just once
});

This should be enough to get you going, but please read the full enquire.js documentation if you wish to learn about the other cool features.

##Contributing

  • Got an awesome idea?
  • Found a not-so-awesome bug?
  • Wish to get my attention through an inappropriate communication channel?!

Then please don't hesitate to raise an issue, they will all be looked at and tended to.

And for all the cool cats who are prepared to give their time to contribute code, feel free to open a pull request. If you could write unit tests to accompany your pull request that would be pretty sweet, but no worries if not - if it's good enough to be merged in, it's good enough for me to spend a little time to write tests on your behalf :-)

##License

License: MIT (http://www.opensource.org/licenses/mit-license.php)

enquire.js's People

Contributors

wickynilliams avatar sboudrias avatar nnnnathann avatar thlorenz avatar samtiffin avatar

Watchers

Vishwas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.