sd

scroll-doc

Feature detected access to the scroller element

Showing:

Popularity

Downloads/wk

16.5K

GitHub Stars

10

Maintenance

Last Commit

4yrs ago

Contributors

3

Package

Dependencies

0

Size (min+gzip)

0.3KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100