Skip to content

Instantly share code, notes, and snippets.

@MkShaman
Created February 4, 2016 06:04
Show Gist options
  • Select an option

  • Save MkShaman/a12703e8516d19afa832 to your computer and use it in GitHub Desktop.

Select an option

Save MkShaman/a12703e8516d19afa832 to your computer and use it in GitHub Desktop.
var s = $(".catalog_filter > form");
var pos = s.offset();
var $catalogR = $('.catalog .catalog_right');
var item = $catalogR.find('.item');
$(window).scroll(function() {
var HCatalog = $catalogR.height();
var marginItem = item.outerHeight(true) - item.height();
var FilterH = $('.catalog_filter').height((HCatalog-marginItem-$catalogR.find('nav.pageNav').outerHeight(true))+'px');
/*bottom*/
var topCat = $catalogR.offset();
var bottom = Math.abs(Math.abs(Math.abs($(window).height() - topCat.top) - Math.abs($catalogR.height()-$catalogR.find('nav.pageNav').outerHeight(true))) - marginItem);
// var topFilt = $('.catalog_filter').offset();
// var bottom = Math.abs(($('.catalog_filter').outerHeight(true)+topFilt.top)-s.height()-10);
// alert(bottom);
var windowpos = $(window).scrollTop();
// $(".catalog_filter > form .title").html(windowpos+' dd '+bottom);
if (windowpos >= pos.top ) {
s.addClass("stick");
s.removeClass("pos-bottom");
if (windowpos >= bottom) {
s.removeClass("stick");
s.addClass('pos-bottom');
}
} else {
s.removeClass("stick");
s.removeClass("pos-bottom");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment