1.0.7 • Published 7 years ago

scrolld v1.0.7

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Scrolld

Javascript plugin that will tell how far a thing has been vertically scrolld.

Install

npm install scrolld --save

Usage

Instantiate a Scrolld object and pass a target in the constructor. If target is empty, then document set as target.

var scrolld = new Scrolld();
console.log(scrolld.percent())

Passing a target:

var scrolldOnElement = new Scrolld(document.querySelector('#selector'));
console.log(scrolldOnElement.percent())

Actually using it for something:

var scrolld = new Scrolld(), 
    token = -1, 
    scrolling = false;

window.addEventListener("scroll", function (e) {
    scrolling = true;

    console.log(scrolld.percent());

    if (token !== -1)
        clearTimeout(token);
    token = setTimeout(function () {
        scrolling = false;
    }, 500);
});

Tested on #document, TEXTAREA and DIV

Try Scrolld

Demo - Todo: make TEXTAREA and DIV demo...

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago