1.0.4 • Published 5 years ago

scroll-parents v1.0.4

Weekly downloads
9
License
ISC
Repository
github
Last release
5 years ago

scroll-parents

Simple function that returns an array with all the scrolling parent nodes of a given element. Useful if an element needs to listen to the scroll event of all it's parent nodes.

Install

npm install scroll-parents --save

Examples

With scrolling parents

<html>
    <body>
        <div id="scrolling-parent" style="overflow:scroll;">
            <div id="my-id"></div>
        </div>
    </body>
</html>
import scrollParents from 'scroll-parents';

const myNode = document.getElementById('my-id');

scrollParents(myNode); // Output: [scrollingParent, Window]

The array is ordered from closest scrolling parent (left) to most distant scrolling parent (right), always ending with the Window object.

Without scrolling parents

<html>
    <body>
        <div id="my-id"></div>
    </body>
</html>
import scrollParents from 'scroll-parents';

const myNode = document.getElementById('my-id');

scrollParents(myNode); // Output: [Window]

License

ISC

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago