Created
August 15, 2017 11:12
-
-
Save Rycochet/1a9933b7fa51a1139c486a9e2ffc5da8 to your computer and use it in GitHub Desktop.
Revisions
-
Rycochet created this gist
Aug 15, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ /** * Get the height of the display, based on body height, then the lowest element within it */ function getHeight(): number { var i = 0, body = document.body, style = body.style, elements = document.querySelectorAll("body *"), best = body.offsetHeight + (parseInt(style.marginTop, 10) || 0) + (parseInt(style.marginBottom, 10) || 0);; while (i < elements.length) { let element = elements[i++], bottom = element.getBoundingClientRect().bottom + (parseInt(getComputedStyle(element).marginBottom, 10) || 0); if (bottom > best) { best = bottom; } } return best; }