scrollparent

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

ISC 6 个版本
安装
npm install scrollparent
yarn add scrollparent
pnpm add scrollparent
bun add scrollparent
README

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

版本列表
2.1.0 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