diff --git a/README.md b/README.md index f9cfddc..6f21fbe 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,15 @@ body{ ```javascript hotcss.mresize(); ``` +#### hotcss.callback +触发mresize的时候会执行该方法。 +```javascript +hotcss.callback = function(){ + //your code here +} +``` + + #### 单位转换hotcss.px2rem/hotcss.rem2px `hotcss.px2rem` 和 `hotcss.rem2px`。你可以预先设定`hotcss.designWidth`可以在meta中设置`design-width`,则之后使用这两个方法不需要再传递第二个参数。 diff --git a/example/hotcss.js b/example/hotcss.js index e99e7cd..c4a3b41 100644 --- a/example/hotcss.js +++ b/example/hotcss.js @@ -14,6 +14,8 @@ maxWidth = 540, designWidth = 0; + dpr = dpr >= 3 ? 3 : ( dpr >=2 ? 2 : 1 ); + //允许通过自定义name为hotcss的meta头,通过initial-dpr来强制定义页面缩放 if (hotcssEl) { var hotcssCon = hotcssEl.getAttribute('content'); @@ -90,6 +92,8 @@ document.documentElement.style.fontSize = ( innerWidth*20/320 ) + 'px'; + hotcss.callback && hotcss.callback(); + }; hotcss.mresize(); diff --git a/src/hotcss.js b/src/hotcss.js index 74b669c..7aa12cc 100644 --- a/src/hotcss.js +++ b/src/hotcss.js @@ -14,6 +14,8 @@ maxWidth = 540, designWidth = 0; + dpr = dpr >= 3 ? 3 : ( dpr >=2 ? 2 : 1 ); + //允许通过自定义name为hotcss的meta头,通过initial-dpr来强制定义页面缩放 if (hotcssEl) { var hotcssCon = hotcssEl.getAttribute('content'); @@ -90,6 +92,8 @@ document.documentElement.style.fontSize = ( innerWidth*20/320 ) + 'px'; + hotcss.callback && hotcss.callback(); + }; hotcss.mresize();