# scrollparent

> A function to get the scrolling parent of an html element.

Latest version **2.1.0** (published 2023-05-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install scrollparent
pnpm add scrollparent
yarn add scrollparent
bun add scrollparent
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-05-28 |
| First published | 2015-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/scrollparent) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 58 |
| Author | Ola Holmström |
| Maintainers | olahol |
| Keywords | browser, scroll, scrollparent, dom |

## Links

- npm: https://www.npmjs.com/package/scrollparent
- Repository: https://github.com/olahol/scrollparent.js
- Homepage: https://github.com/olahol/scrollparent.js#readme
- Issues: https://github.com/olahol/scrollparent.js/issues
- npm.io page: https://npm.io/package/scrollparent

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2023-05-28
- 2.0.1 — 2017-04-10
- 2.0.0 — 2017-04-09
- 1.0.2 — 2016-10-17
- 1.0.0 — 2016-03-18
- 0.1.0 — 2015-07-08

## README

# scrollparent

[![NPM version][npm-image]][npm-url]
[![Size][size-image]][size-url]
[![Download count][downloads-image]][downloads-url]
![Build status][build-image]

A function to get the scrolling parent of a html element.

## Install

```bash
npm install scrollparent --save
```

## Example

```js
var Scrollparent = require("scrollparent");

Scrollparent(document.getElementById("content")) // HTMLHtmlElement or HTMLBodyElement as appropriate
```

```js
var Scrollparent = require("scrollparent");

Scrollparent(document.getElementById("inside-a-scrolling-div")) // HTMLDivElement
```

## Note about the root scrolling element

Internally, the root scrolling element is determined in this library
as the result of

```js
document.scrollingElement || document.documentElement;
```

This should give a usable result in most browsers today
but if you want to ensure full support
you should use a `document.scrollingElement` polyfill such as
[this one](https://github.com/mathiasbynens/document.scrollingElement).

## Contributors

<a href="https://github.com/olahol/scrollparent.js/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=olahol/scrollparent.js" />
</a>

## License

MIT

[build-image]: https://github.com/olahol/scrollparent.js/actions/workflows/playwright.yml/badge.svg
[npm-image]: https://img.shields.io/npm/v/scrollparent.svg
[npm-url]: https://npmjs.org/package/scrollparent
[downloads-image]: http://img.shields.io/npm/dm/scrollparent.svg
[downloads-url]: https://npmjs.org/package/scrollparent
[size-image]: https://img.badgesize.io/olahol/scrollparent.js/master/scrollparent.js.svg
[size-url]: https://github.com/olahol/scrollparent.js/blob/master/scrollparent.js

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