From 99e9fe41a3e6f2baa20d1d7bcbbeaafbcdf32db5 Mon Sep 17 00:00:00 2001 From: mochen Date: Thu, 3 Mar 2016 09:56:50 +0800 Subject: [PATCH] =?UTF-8?q?mresize=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96dpr=E4=B8=BA=E6=95=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++++ example/hotcss.js | 4 ++++ src/hotcss.js | 4 ++++ 3 files changed, 17 insertions(+) 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();