$(window).scroll(function() doesn't fire, always undefined

1.1k Views Asked by At

I can't understand why on my localhost this doenst work at all? The $(window).scroll(function() won't fire. Am I missing something? is this code a total disaster?

var module =  {
    init: function () {
      this.fixHeader();
    },

    fixHeader: function () {

      var sticky = $('.header'),
      stickyHeight = $(sticky).outerHeight(),
      stickyTop = $(sticky).offset().top,
      stickyBottom = stickyTop + stickyHeight;

       $(window).scroll(function(){
        console.log('dasdasdasdasdas');
        var scrollTop = $(window).scrollTop();

        if(scrollTop > stickyBottom){
            $(sticky).addClass('sticky');
        }else{
            $(sticky).removeClass('sticky');
        }
      });

        $(sticky).on('click', '.logo', function(){
          $('html, body').animate({scrollTop: 0} ,'slow');
        });


    }
};

$(document).ready(function () {
  module.init();
});
0

There are 0 best solutions below