Skip to content

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

License

Notifications You must be signed in to change notification settings

j0o009k/scrollparent.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrollparent.js

A function to get the scrolling parent of an 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

  • Ola Holmström (@olahol)
  • Bart Nagel (@tremby)
  • Daniel White (@danbrianwhite)

License

MIT

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 82.2%
  • JavaScript 17.8%