Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including scroll-past with all npm packages installed. Try it out:

var scrollPast = require("scroll-past")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

scroll-past v2.0.0

Return a promise when any element is scroll past

scroll-past

Return a Promise when any element is scroll past

Install

$ npm install scroll-past

Usage

const scrollPast = require('scroll-past');

scrollPast(document.querySelector('.container')).then(pos => {
    console.log(`I'm at ${pos}`);
});

API

scrollPast(element, [options])

Returns a Promise that resolves the scrollY position of the window.

element

Type: Element

The element to check for.

options

threshold

Type: number
Default: 0

Add a threshold to scroll past before the Promise is returned.

License

MIT © Kevin Mårtensson

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free