• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

WickyNilliams/enquire.js: Awesome Media Queries in JavaScript

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

WickyNilliams/enquire.js

开源软件地址:

https://github.com/WickyNilliams/enquire.js

开源编程语言:

JavaScript 85.3%

开源软件介绍:

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 bower, enter the following at the command line:

bower install enquire

Install via npm

To install via npm, enter the following at the command line:

npm install enquire.js

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)




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap