SnippetVamp

Because spending time searching snippets sucks.



javascript 3 jquery 3 php 1 vanilla 3

.

Détection du scroll vertical (haut / bas)

Détection du scroll vertical (haut / bas)

// Initial state
var scrollPos = 0;
// adding scroll event
window.addEventListener('scroll', function(){ scrolling() });

// the function : compares the "new" scrolling state with the previous
// (this allows detecting either "up" or "down" scrolling)
// then saves the new in the $previous for the next iteration.

function scrolling() {
    if ((document.body.getBoundingClientRect()).top > scrollPos) {
        console.log('scrolling DOWN');
    } else {
        console.log('scrolling UP');
    }
    scrollPos = (document.body.getBoundingClientRect()).top;
}

javascript vanilla

http://lehollandaisvolant.net/?mode=links&id=20160224192625

<iframe width="100%" height="488" src="http://raphael.salique.fr/snippetvamp/index.php?embed=56d2d85282db9" type="text/html"></iframe>

Texte seul - Permalink - Snippet public posté le 28/02/2016

Flux RSS de cette page


SnippetVamp 1.84 par Bronco - Page générée en 0.018 s