|
6 | 6 | [![NPM downloads][npm-downloads-image]][npm-url]
|
7 | 7 | [![MIT License][license-image]][license-url]
|
8 | 8 |
|
| 9 | +## Usage |
| 10 | + |
| 11 | +```js |
| 12 | +import viewport from 'bianco.viewport' |
| 13 | + |
| 14 | +// get the current scroll top position |
| 15 | +const offsetTop = viewport.scrollTop() |
| 16 | +``` |
| 17 | + |
9 | 18 | [travis-image]: https://img.shields.io/travis/biancojs/viewport.svg?style=flat-square
|
10 | 19 |
|
11 | 20 | [travis-url]: https://travis-ci.org/biancojs/viewport
|
|
24 | 33 |
|
25 | 34 | <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
26 | 35 |
|
| 36 | +#### Table of Contents |
| 37 | + |
| 38 | +- [scrollbarWidth](#scrollbarwidth) |
| 39 | +- [documentHeight](#documentheight) |
| 40 | +- [documentWidth](#documentwidth) |
| 41 | +- [scrollTop](#scrolltop) |
| 42 | +- [scrollLeft](#scrollleft) |
| 43 | +- [elementOffsetTop](#elementoffsettop) |
| 44 | + - [Parameters](#parameters) |
| 45 | +- [elementOffsetLeft](#elementoffsetleft) |
| 46 | + - [Parameters](#parameters-1) |
| 47 | + |
27 | 48 | ### scrollbarWidth
|
28 | 49 |
|
29 | 50 | Return the size of the scrollbar that depends on the browser or device used on the client
|
30 | 51 |
|
31 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the browser scrollbar width |
| 52 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the browser scrollbar width |
32 | 53 |
|
33 | 54 | ### documentHeight
|
34 | 55 |
|
35 | 56 | Get the height of the whole page
|
36 | 57 |
|
37 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** height in px of the document |
| 58 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** height in px of the document |
38 | 59 |
|
39 | 60 | ### documentWidth
|
40 | 61 |
|
41 | 62 | Get the width of the whole page
|
42 | 63 |
|
43 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** width in px of the document |
| 64 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** width in px of the document |
44 | 65 |
|
45 | 66 | ### scrollTop
|
46 | 67 |
|
47 | 68 | Return amount of px scrolled from the top of the document
|
48 | 69 |
|
49 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll top value in px |
| 70 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll top value in px |
50 | 71 |
|
51 | 72 | ### scrollLeft
|
52 | 73 |
|
53 | 74 | Return amount of px scrolled from the left of the document
|
54 | 75 |
|
55 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll left value in px |
| 76 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll left value in px |
56 | 77 |
|
57 | 78 | ### elementOffsetTop
|
58 | 79 |
|
59 | 80 | Get the offset top of any DOM element
|
60 | 81 |
|
61 |
| -**Parameters** |
| 82 | +#### Parameters |
62 | 83 |
|
63 |
| -- `el` **[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element)** the element we need to check |
| 84 | +- `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** the element we need to check |
64 | 85 |
|
65 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element y position in px |
| 86 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element y position in px |
66 | 87 |
|
67 | 88 | ### elementOffsetLeft
|
68 | 89 |
|
69 | 90 | Get the offset left of any DOM element
|
70 | 91 |
|
71 |
| -**Parameters** |
| 92 | +#### Parameters |
72 | 93 |
|
73 |
| -- `el` **[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element)** the element we need to check |
| 94 | +- `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** the element we need to check |
74 | 95 |
|
75 |
| -Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element x position in px |
| 96 | +Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element x position in px |
0 commit comments