Skip to content

GreenGremlin/scroll-doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrollDoc

Feature detected access to the scroller element

import scrollDoc from 'scroll-doc';

const scrollElement = scrollDoc();

// scroll to the top
scrollElement.scrollTop = 0;

How it works

ScrollDoc uses feature detection to detect which element is valid for scrolling the document. It attempts to scroll 1px using document.documentElement if it succeeds, it will reset document.documentElement to it's original scroll position and return document.documentElement; if it fails, it will return document.body. The result is cached and the cached value is returned on subsequent calls.

About

Feature detected access to the scroller element

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published