-1

I need to convert the fallowing working script as so it works on scroll regardless of how the site is being scrolled.

    // // HEADER 
    $(window).bind('mousewheel', function(event) {
        if ($(document).scrollTop() <= 20 || event.originalEvent.wheelDelta > 0 && $(document).scrollTop() <= 105) {
            //console.log('large');
            headerLarge();
        }
        else if (event.originalEvent.wheelDelta > 0 && $(document).scrollTop() <= 120) {
            //console.log('medium');
            headerMed();
        } 
        else if (event.originalEvent.wheelDelta < 0 && $(document).scrollTop() >= 100) {
            //console.log('small');
            headerSm();
        }
    }); 

I tried using the following without success:

$(document).on('scroll', function(event) { ...

user2300867
  • 593
  • 1
  • 12
  • 28

2 Answers2

0

This should work

$(window).scroll(function(){

});
Bruno Calza
  • 2,732
  • 2
  • 23
  • 25
  • 1
    Well but I still have event.originalEvent.wheelDelta on if statements, any suggestions on how to get same functionality using scroll? – user2300867 Oct 31 '14 at 19:23
  • humm. i don't think scroll event comes with this data. what you're trying to accomplish? if you're trying to detect the scroll orientation, there's a solution for that on http://stackoverflow.com/questions/4326845/how-can-i-determine-the-direction-of-a-jquery-scroll-event – Bruno Calza Oct 31 '14 at 20:13
0

You can do it using $(window).scroll() like this:

 $(window).scroll(function() {   

       alert("scrolling!");

});

Taken From Infinite Scroll Paging

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160