Skip to content

Instantly share code, notes, and snippets.

View makingthingswork's full-sized avatar

Making Things Work makingthingswork

View GitHub Profile
@makingthingswork
makingthingswork / viewport.js
Last active November 19, 2020 14:32
Accurately (and reliably) return the width and height of the viewport
var viewport = function() {
var e = window, a = 'inner';
if (!( 'innerWidth' in window)){
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[a+'Width'], height : e[a+'Height'] };
};