You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/06/07 08:05:55 UTC

[18/50] incubator-weex git commit: * [html5] fix dom.getComponentRect.

* [html5] fix dom.getComponentRect.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/948452fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/948452fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/948452fa

Branch: refs/heads/dev
Commit: 948452faebd7b83c6f6f21a9bf0a05af297723b6
Parents: 5350069
Author: MrRaindrop <te...@gmail.com>
Authored: Sat May 27 15:19:32 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Sat May 27 15:19:32 2017 +0800

----------------------------------------------------------------------
 html5/render/vue/modules/dom.js | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/948452fa/html5/render/vue/modules/dom.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/dom.js b/html5/render/vue/modules/dom.js
index 2efccfc..8280ab5 100644
--- a/html5/render/vue/modules/dom.js
+++ b/html5/render/vue/modules/dom.js
@@ -160,22 +160,32 @@ export default {
       vnode = vnode[0]
     }
 
+    const scale = window.weex.config.env.scale
     const info = { result: false }
+    const rectKeys = ['width', 'height', 'top', 'bottom', 'left', 'right']
+
+    function recalc (rect) {
+      const res = {}
+      rectKeys.forEach(key => {
+        res[key] = rect[key] / scale
+      })
+      return res
+    }
 
     if (vnode && vnode === 'viewport') {
       info.result = true
-      info.size = {
+      info.size = recalc({
         width: document.documentElement.clientWidth,
         height: document.documentElement.clientHeight,
         top: 0,
         left: 0,
         right: document.documentElement.clientWidth,
         bottom: document.documentElement.clientHeight
-      }
+      })
     }
     else if (vnode && vnode.$el) {
       info.result = true
-      info.size = vnode.$el.getBoundingClientRect()
+      info.size = recalc(vnode.$el.getBoundingClientRect())
     }
 
     const message = info.result ? info : {