diff options
author | Ryan Van Etten <ryanve@gmail.com> | 2013-11-20 20:22:08 -0500 |
---|---|---|
committer | Ryan Van Etten <ryanve@gmail.com> | 2013-11-20 20:22:08 -0500 |
commit | 5a2c415ef46ac8f9fdf571ba33da462b24e29ce3 (patch) | |
tree | 86e4967e3f977b8ea106057fc1232dc0f0917dbb | |
parent | 69f114d58387cc8f99b9127e7558996f437cd65e (diff) | |
download | verge-5a2c415ef46ac8f9fdf571ba33da462b24e29ce3.zip verge-5a2c415ef46ac8f9fdf571ba33da462b24e29ce3.tar.gz verge-5a2c415ef46ac8f9fdf571ba33da462b24e29ce3.tar.bz2 |
Document the 1.8+ .viewport() syntax.
-rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -22,6 +22,7 @@ The docs below use <b>$</b> to denote <b>verge</b> or a [host lib](#integrate). - <a href="#scrolly"><b>$.scrollY()</b></a> - <a href="#viewportw"><b>$.viewportW()</b></a> - <a href="#viewporth"><b>$.viewportH()</b></a> +- <a href="#viewport"><b>$.viewport()</b></a> *** @@ -37,6 +38,24 @@ $.viewportW() // -> viewport width in pixels $.viewportH() // -> viewport height in pixels ``` +### $.viewport() + +Get an <b>object</b> with width and height properties—an alternate syntax to get both viewport dimensions. + +```js +$.viewportW() === $.viewport().width // always true +$.viewportH() === $.viewport().height // always true +``` + +#### The [`.viewportW()`](#viewportw) syntax is faster. +##### Mitigate the speed difference with local vars. + +```js +var current = $.viewport() + , width = current.width + , height = current.height +``` + ### $.inViewport() Test if any part of an element (or the first element in a matched set) is in the current viewport. Returns **boolean**. |