KaiserEMP
9/18/2018 - 7:39 AM

Scroll fixed box(blue block)

assd

function outMenu() {
  var openHeader = $('header.header > .container').outerHeight();
  var headerBlock = $('.eda-module-type-slider .outer');
  //console.log(openHeader);
  var scrollDistance = $(window).scrollTop();
  //console.log('scroll ' + scrollDistance);
  var windowHeight = $(window).outerHeight();
  //console.log('window ' + windowHeight);

  var sliderHeight = $('.eda-module-type-slider').outerHeight();
  var distanceFromTop = openHeader + sliderHeight + 40;
  //console.log('distanceFromTop' + distanceFromTop);
  var viewEdge = windowHeight + scrollDistance;
  if (windowHeight <= 865) {
    if (viewEdge < distanceFromTop) {
      headerBlock.addClass('fixedBlock');
     } else if (viewEdge >= distanceFromTop) {
       headerBlock.removeClass('fixedBlock');
    }
  } else {
    headerBlock.removeClass('fixedBlock');
  }
}
$(window).on('load resize',function() {
  outMenu();
});
$(window).scroll(function(){
  outMenu();
});