ryanve / verge

get viewport dimensions...detect elements in the viewport...trust in <!DOCTYPE html>
https://ryanve.dev/verge
MIT License
695 stars 51 forks source link

viewportH returns document height, not viewport height. #12

Closed ericandrewlewis closed 10 years ago

ericandrewlewis commented 10 years ago

viewportH more or less defaults to returning document element's height, which doesn't describe the "viewport" height. Shouldn't we always refer to window.innerHeight?

ryanve commented 10 years ago

Thanks for checking @ericandrewlewis. By design verge.viewportH() gets the CSS @media (height) because that seems like the most useful value. Please report if different. window.innerHeight is inaccurate sometimes.

In that code docElem is the document.documentElement or falsey. The typechecks prevent throwing errors in environments like node where window and document are undefined.