diff --git a/webroot/rsrc/js/core/behavior-device.js b/webroot/rsrc/js/core/behavior-device.js --- a/webroot/rsrc/js/core/behavior-device.js +++ b/webroot/rsrc/js/core/behavior-device.js @@ -26,6 +26,19 @@ var v = JX.Vector.getViewport(); var self = JX.Device; + // Even when we emit a '' tag which tells + // devices to fit the conent to the screen width, we'll sometimes measure + // a viewport dimension which is larger than the available screen width, + // particularly if we check too early. + + // If the device provides a screen width and the screen width is smaller + // than the viewport width, use the screen width. + + var screen_width = (window.screen && window.screen.availWidth); + if (screen_width) { + v.x = Math.min(v.x, screen_width); + } + var device = 'desktop'; if (v.x <= self._tabletBreakpoint) { device = 'tablet';