1. scrollparent
A function to get the scrolling parent of an html element.
scrollparent
Package: scrollparent
Created by: olahol
Last modified: Sun, 28 May 2023 21:13:29 GMT
Version: 2.1.0
License: ISC
Downloads: 1,943,694
Repository: https://github.com/olahol/scrollparent.js

Install

npm install scrollparent
yarn add scrollparent

scrollparent

NPM version
Size
Download count
Build status

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

Install

 npm install scrollparent --save

Example

 var Scrollparent = require("scrollparent");

Scrollparent(document.getElementById("content")) // HTMLHtmlElement or HTMLBodyElement as appropriate
 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

 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.

Contributors

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code