类似css媒体查询能在不同屏幕下判断的js轻量级js库enquire.js

2020年05月27日 阅读308次 分类:资源 标签:js资源

版权声明:本文为博主原创或转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:http://www.zhuyanjun.cn/resource/1177.html

enquire.js插件

enquire.js 是轻量级,纯 JavaScript 实现的 CSS 媒体查询库。

  • JavaScript 回调媒体查询,匹配或者不匹配

  • 干净直观的 API

  • 超轻量级 —— 大约 0.8kb minified & gzipped!

完全无依赖,甚至是 jQuery。

enquire.register("screen and (max-width:45em)", {
    // OPTIONAL    
    // If supplied, triggered when a media query matches.   
     match : function() {},      
                                
    // OPTIONAL    
    // If supplied, triggered when the media query transitions     
    // *from a matched state to an unmatched state*.    
    unmatch : function() {},    
    
    // OPTIONAL    
    // If supplied, triggered once, when the handler is registered.    
    setup : function() {},    
                                
    // OPTIONAL, defaults to false    
    // If set to true, defers execution of the setup function     
    // until the first time the media query is matched    
    deferSetup : true,
                                
    // OPTIONAL    
    // If supplied, triggered when handler is unregistered.     
    // Place cleanup code here    
    destroy : function() {}
      
});
使用场景 判断浏览器宽度,响应式网站开发
npm包名 enquire.js
bower包名
文档地址 点击访问


上一篇:粒子动效插件

下一条:3d模型展示插件

(本篇完)

是不是学到了很多?可以

版权声明:本文为博主原创或转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:http://www.zhuyanjun.cn/resource/1177.html