diff --git a/src/browser/DomElement.js b/src/browser/DomElement.js index aa7ee55d..6a70a227 100644 --- a/src/browser/DomElement.js +++ b/src/browser/DomElement.js @@ -41,15 +41,26 @@ var DomElement = new function() { } return { - getWindow: function(doc) { + getViewport: function(doc) { return doc.defaultView || doc.parentWindow; }, + getViewportSize: function(el) { + var doc = el.ownerDocument, + view = DomElement.getViewport(doc), + body = doc.getElementsByTagName( + doc.compatMode === 'CSS1Compat' ? 'html' : 'body')[0]; + return Size.create( + view.innerWidth || body.clientWidth, + view.innerHeight || body.clientHeight + ); + }, + getComputedStyle: function(el, name) { if (el.currentStyle) return el.currentStyle[Base.camelize(name)]; - var style = DomElement.getWindow(el.ownerDocument).getComputedStyle( - el, null); + var style = DomElement.getViewport(el.ownerDocument) + .getComputedStyle(el, null); return style ? style.getPropertyValue(Base.hyphenate(name)) : null; }, @@ -77,15 +88,6 @@ var DomElement = new function() { DomElement.getSize(el)); }, - getWindowSize: function() { - var doc = document.getElementsByTagName( - document.compatMode === 'CSS1Compat' ? 'html' : 'body')[0]; - return Size.create( - window.innerWidth || doc.clientWidth, - window.innerHeight || doc.clientHeight - ); - }, - /** * Checks if element is invisibile (display: none, ...) */ @@ -100,7 +102,7 @@ var DomElement = new function() { // See if the viewport bounds intersect with the windows rectangle // which always starts at 0, 0 return !DomElement.isInvisible(el) - && new Rectangle([0, 0], DomElement.getWindowSize()) + && new Rectangle([0, 0], DomElement.getViewportSize(el)) .intersects(DomElement.getBounds(el, false, true)); } }; diff --git a/src/ui/View.js b/src/ui/View.js index 8ab6428f..61cc4e70 100644 --- a/src/ui/View.js +++ b/src/ui/View.js @@ -40,7 +40,7 @@ var View = this.View = Base.extend(/** @lends View# */{ // stretch it in var offset = DomElement.getOffset(canvas, false, true), that = this; - size = DomElement.getWindowSize().subtract(offset); + size = DomElement.getViewportSize(canvas).subtract(offset); canvas.width = size.width; canvas.height = size.height; DomEvent.add(window, { @@ -50,8 +50,8 @@ var View = this.View = Base.extend(/** @lends View# */{ if (!DomElement.isInvisible(canvas)) offset = DomElement.getOffset(canvas, false, true); // Set the size now, which internally calls onResize - that.setViewSize( - DomElement.getWindowSize().subtract(offset)); + that.setViewSize(DomElement.getViewportSize(canvas) + .subtract(offset)); // If there's a _onFrameCallback, call it staight away, // but without requesting another animation frame. if (that._onFrameCallback) {