scrollparent

v2.0.1
A function to get the scrolling parent of an html element.
browser scroll scrollparent dom

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

Metadata

  • ISC
  • Whatever
  • Ola Holmström
  • released 4/10/2017

Downloads

Maintainers