From 0456a2855efbcd1cb978a6893da0e25a78cf97f7 Mon Sep 17 00:00:00 2001 From: Danny Cheng Date: Tue, 19 Jun 2018 14:41:40 -0500 Subject: [PATCH] Replace a check on body.clientWidth with window.innerWidth because when we call window.matchMedia, it checks window.innerWidth. --- src/manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/manager.js b/src/manager.js index ba4c20e..0f3a5eb 100644 --- a/src/manager.js +++ b/src/manager.js @@ -29,7 +29,7 @@ var AdManager = function (options) { this.adId = 0; this.initialized = false; this.viewportWidth = 0; - this.oldViewportWidth = window.document.body.clientWidth; + this.oldViewportWidth = window.innerWidth; this.options = utils.extend(defaultOptions, options); this.bindContext(); @@ -90,7 +90,7 @@ AdManager.prototype.handleWindowResize = function () { return; } - this.viewportWidth = window.document.body.clientWidth; + this.viewportWidth = window.innerWidth; if (!this.oldViewportWidth || this.oldViewportWidth !== this.viewportWidth) { // viewport size has actually changed, reload ads @@ -314,7 +314,7 @@ AdManager.prototype.generateId = function () { * @returns {Integer} client width in pixels */ AdManager.prototype.getClientWidth = function () { - return window.document.body.clientWidth; + return window.innerWidth; }; /**