enquire.js传统支持 [英] enquire.js legacy support

查看:462
本文介绍了enquire.js传统支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图找出让enquire.js在旧版浏览器上工作的最佳方法(即6-9)。在查询的网站上,它说使用modernizr检查matchMedia支持,然后加载polyfill,如果它不受支持。

I'm trying to figure out what the best way to get enquire.js to work on legacy browsers (ie 6-9). On enquire's site, it says to use modernizr to check for matchMedia support, then load a polyfill if it's not supported.

Modernizr.load([
    //first test need for polyfill
    {
        test: window.matchMedia,
        nope: "/path/to/polyfill.js"
    },

    //and then load enquire
    "/path/to/enquire.js"
]);

看看它建议的polyfill,它说modernizr已经将它包含在Modernizr.mq()中。

Looking at the polyfill that it suggests, it says that modernizr already includes it with Modernizr.mq().

    Used in:
    Respond.js
    FormFactor
    Modernizr
https://github.com/paulirish/matchMedia.js/

我调查了这个,但是可以找不到让这项工作的方法。

I've looked into this, but can't find a way to make this work.

推荐答案

在这里查询作者!

所以总会有一点混乱关于matchMedia polyfill。它不会将CSS3媒体查询支持填充到旧版浏览器中。它的作用是为那些支持CSS3媒体查询但不提供此API的浏览器填充matchMedia javascript API。有关对matchMedia的支持,请参阅此处。例如,IE9支持CSS3媒体查询,但没有matchMedia JS API,这是Paul Irish的matchMedia polyfill的目标。

So there's always a little confusion about the matchMedia polyfill. It doesn't polyfill CSS3 media query support into legacy browsers. What it does is polyfill the matchMedia javascript API for those browsers that support CSS3 media queries but do not offer this API. See here for support for matchMedia. For instance, IE9 supports CSS3 media queries, but doesn't have the matchMedia JS API, this is the target of Paul Irish's matchMedia polyfill.

如果你正在寻找一个功能齐全的polyfill,它为老版浏览器提供了不错的媒体查询支持,我可以建议使用David Knight的媒体匹配吗?我和他一起工作来测试这个并且已经证明支持一直回到IE6 - 它有点魅力:)你可以在这里找到: https://github.com/weblinc/media-match 。您可以完全按照我对Modernizr的建议有条件地加载它,只需更换相应的部件。

If you're looking for a fully featured polyfill, that gives decent media query suport to older browsers, can I suggest using David Knight's media-match? I have worked in conjunction with him to test this and have proven support all the way back to IE6 - it works a charm :) You can find that here: https://github.com/weblinc/media-match. You can conditionally load it exactly as I suggested with Modernizr, just replace the appropriate parts.

希望有帮助,很乐意回答您的任何其他问题。

Hope that helps, happy to answer any further questions you have.

这篇关于enquire.js传统支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆