Skip to content

Instantly share code, notes, and snippets.

@overwine
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save overwine/d5cf59ab2a907b9cebde to your computer and use it in GitHub Desktop.

Select an option

Save overwine/d5cf59ab2a907b9cebde to your computer and use it in GitHub Desktop.

Revisions

  1. overwine revised this gist Aug 6, 2015. 1 changed file with 21 additions and 18 deletions.
    39 changes: 21 additions & 18 deletions newbs.js
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,23 @@
    var lastScrollTop = 0;
    console.log(lastScrollTop);
    var lastScrollTop;
    //console.log(lastScrollTop);

    $(window).scroll(function(event){
    var currentScrollTop = $(window).scrollTop();
    if (currentScrollTop > lastScrollTop){
    $('.top-filter').animate({
    top: "-20px",
    }, 1000);
    //$('body').addClass('has-scrolled')
    console.log(currentScrollTop);
    } else if (currentScrollTop <= lastScrollTop) {
    $('.top-filter').animate({
    top: "147px",
    }, 1000);
    //$('body').removeClass('has-scrolled')
    }
    lastScrollTop = currentScrollTop;
    console.log(currentScrollTop)
    $('.top-filter').stop();
    var currentScrollTop = $(window).scrollTop();
    if (currentScrollTop > lastScrollTop){
    $('.top-filter').animate({
    top: "-20px",
    }, 1000);
    console.log("Scroll down!");
    //$('body').addClass('has-scrolled')
    } else {
    $('.top-filter').animate({
    top: "147px",
    }, 1000);
    console.log("Scroll up!");
    //$('body').removeClass('has-scrolled')
    }
    console.log(lastScrollTop);
    console.log(currentScrollTop);
    lastScrollTop = currentScrollTop;
    });
  2. overwine created this gist Aug 6, 2015.
    20 changes: 20 additions & 0 deletions newbs.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    var lastScrollTop = 0;
    console.log(lastScrollTop);

    $(window).scroll(function(event){
    var currentScrollTop = $(window).scrollTop();
    if (currentScrollTop > lastScrollTop){
    $('.top-filter').animate({
    top: "-20px",
    }, 1000);
    //$('body').addClass('has-scrolled')
    console.log(currentScrollTop);
    } else if (currentScrollTop <= lastScrollTop) {
    $('.top-filter').animate({
    top: "147px",
    }, 1000);
    //$('body').removeClass('has-scrolled')
    }
    lastScrollTop = currentScrollTop;
    console.log(currentScrollTop)
    });