# bianco.viewport

> [![Build Status][ci-image]][ci-url] [![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url]

Latest version **1.1.0** (published 2022-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install bianco.viewport
pnpm add bianco.viewport
yarn add bianco.viewport
bun add bianco.viewport
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-03-10 |
| First published | 2017-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Gianluca Guarini |
| Maintainers | gianlucaguarini |
| Keywords | es6, es2015 |

## Links

- npm: https://www.npmjs.com/package/bianco.viewport
- Repository: https://github.com/biancojs/viewport
- Homepage: https://github.com/biancojs/viewport#readme
- Issues: https://github.com/biancojs/viewport/issues
- npm.io page: https://npm.io/package/bianco.viewport

## Recent versions

- 1.1.0 (latest) — 2022-03-10
- 1.0.0 — 2018-12-01
- 0.0.5 — 2018-06-03
- 0.0.4 — 2018-05-03
- 0.0.2 — 2017-11-10
- 0.0.1 — 2017-11-10

## README

# bianco.viewport

[![Build Status][ci-image]][ci-url]
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]

## Usage

```js
import viewport from 'bianco.viewport'

// get the current scroll top position
const offsetTop = viewport.scrollTop()
```

[ci-image]:https://img.shields.io/github/workflow/status/biancojs/viewport/test?style=flat-square
[ci-url]:https://github.com/biancojs/viewport/actions

[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square

[license-url]: LICENSE.txt

[npm-version-image]: http://img.shields.io/npm/v/bianco.viewport.svg?style=flat-square

[npm-downloads-image]: http://img.shields.io/npm/dm/bianco.viewport.svg?style=flat-square

[npm-url]: https://npmjs.org/package/bianco.viewport

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [scrollbarWidth](#scrollbarwidth)
-   [documentHeight](#documentheight)
-   [documentWidth](#documentwidth)
-   [scrollTop](#scrolltop)
-   [scrollLeft](#scrollleft)
-   [elementOffsetTop](#elementoffsettop)
    -   [Parameters](#parameters)
-   [elementOffsetLeft](#elementoffsetleft)
    -   [Parameters](#parameters-1)

### scrollbarWidth

Return the size of the scrollbar that depends on the browser or device used on the client

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the browser scrollbar width

### documentHeight

Get the height of the whole page

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** height in px of the document

### documentWidth

Get the width of the whole page

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** width in px of the document

### scrollTop

Return amount of px scrolled from the top of the document

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll top value in px

### scrollLeft

Return amount of px scrolled from the left of the document

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** scroll left value in px

### elementOffsetTop

Get the offset top of any DOM element

#### Parameters

-   `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** the element we need to check

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element y position in px

### elementOffsetLeft

Get the offset left of any DOM element

#### Parameters

-   `el` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** the element we need to check

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the element x position in px

---
_Source: https://npm.io/package/bianco.viewport · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
