get-scroll

Micro module to get the scroll position (top or left) in the browser

Usage no npm install needed!

<script type="module">
  import getScroll from 'https://cdn.skypack.dev/get-scroll';
</script>

README

get-scroll gzipped size npm version

Micro module to get the scroll position (top or left) in the browser

Usage

Directly in the browser

Copy the content of dist/get-scroll.browser.js into your JS file and then use it this way:

var currentScrollTop = getScrollTop();
var currentScrollLeft = getScrollLeft();

With browserify/webpack

npm install --save get-scroll
var getScroll = require('get-scroll');

var currentScrollTop = getScroll.top(); // or just getScroll()
var currentScrollLeft = getScroll.left();

In ES6

import {getScrollLeft, getScrollTop} from 'get-scroll';

let currentScrollTop = getScrollTop()
let currentScrollLeft = getScrollLeft()

Dependencies

No dependencies.

License

MIT © Federico Brigante