Skip to content

Commit

Permalink
Modified viewport measuring logic to ensure that it works regardless …
Browse files Browse the repository at this point in the history
…of whether body element is 100% height/width or has margins

Added enyo.dom.getWindowHeight to compliment getWindowWidth
Enyo-DCO-1.1-Signed-off-by: Ian Beck <ian@onecrayon.com>
  • Loading branch information
onecrayon committed Dec 12, 2012
1 parent 72e6599 commit 5fc8cdc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions source/dom/dom.js
Expand Up @@ -69,6 +69,20 @@ enyo.dom = {
}
return 320;
},
getWindowHeight: function() {
if (window.innerHeight) {
return window.innerHeight;
}
if (document.body && document.body.offsetHeight) {
return document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetHeight ) {
return document.documentElement.offsetHeight;
}
return 480;
},
// moved from FittableLayout.js into common protected code
_ieCssToPixelValue: function(inNode, inValue) {
var v = inValue;
Expand Down Expand Up @@ -132,8 +146,8 @@ enyo.dom = {
node = inNode,
width = node.offsetWidth,
height = node.offsetHeight,
docHeight = document.body.offsetHeight,
docWidth = document.body.offsetWidth,
docHeight = (document.body.parentNode.offsetHeight > this.getWindowHeight() ? this.getWindowHeight() - document.body.parentNode.scrollTop : document.body.parentNode.offsetHeight),
docWidth = (document.body.parentNode.offsetWidth > this.getWindowWidth() ? this.getWindowWidth() - document.body.parentNode.scrollLeft : document.body.parentNode.offsetWidth),
transformProp = enyo.dom.getStyleTransformProp(),
xregex = /translateX\((-?\d+)px\)/i,
yregex = /translateY\((-?\d+)px\)/i;
Expand Down

0 comments on commit 5fc8cdc

Please sign in to comment.