Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/olahol/scrollparent.js
A function to get the scrolling parent of a html element.
https://github.com/olahol/scrollparent.js
dom javascript parent scroll scrolling
Last synced: about 21 hours ago
JSON representation
A function to get the scrolling parent of a html element.
- Host: GitHub
- URL: https://github.com/olahol/scrollparent.js
- Owner: olahol
- License: mit
- Created: 2014-04-03T14:14:20.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-05-28T21:14:03.000Z (over 1 year ago)
- Last Synced: 2025-02-01T20:08:41.379Z (8 days ago)
- Topics: dom, javascript, parent, scroll, scrolling
- Language: HTML
- Homepage:
- Size: 26.4 KB
- Stars: 58
- Watchers: 3
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
## 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