yedincifirat
yedincifirat

Reputation: 147

jquery window.scroll doesn't work properly

in this page I have 3 window.scroll functions but my events isn't working properly but if I remove another 2 window.scroll the very first window.scroll function works as expected.My jquery codes are in below

 $(document).scroll(function() {
      var y = $(this).scrollTop();
      if (y > 800) {
        $('.sizi-arayalim').fadeIn();
      } else {
        $('.sizi-arayalim').fadeOut();
      }
    });

    $(document).scroll(function() {
      if (!$("#aniStickyNav").length) {
     return false; //Check if the element exist
  }
  var y = $(this).scrollTop();
  if (y > $(".after-scroll-sticky").offset().top+$(".hotel-search-box").height()) {
    $('#aniStickyNav').show();
  } else {
    $('#aniStickyNav').hide();
  }
});

$(document).scroll(function(){
    if(!$(".hotel-search-box").length){
        return false;
    }
    var y = $(this).scrollTop();
      if (y > $(".hotel-search-box").offset().top) {
        $('.sticky-checkin').show();
      } else {
        $('.sticky-checkin').hide();
      }
});

Upvotes: 0

Views: 224

Answers (1)

Raman Kumar
Raman Kumar

Reputation: 188

you can use if (!$("#aniStickyNav").length) { return false; without putting into scroll function, and try to combine others into just one.

Upvotes: 1

Related Questions