content.js
1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// fixed left/right hand side column affix
var contentPadding = 0,
footerOffset = 0;
if ($('.content').length) {
contentPadding = parseInt($('.content').css('padding-bottom').replace('px', ''));
};
$(window).on('scroll', function() {
$('.content-fix').each(function(index) {
if ($(this).outerHeight() < $(this).closest('.row-fix').outerHeight()) {
contentFix($(this));
}
});
});
function contentFix(content) {
var scrolled = window.innerHeight + window.pageYOffset;
if (window.pageYOffset >= (content.offset().top - headerHeight)) {
if ((content.is('[class*="col-xx"]')) || (content.is('[class*="col-xs"]') && $(window).width() >= 480) || (content.is('[class*="col-sm"]') && $(window).width() >= 768) || (content.is('[class*="col-md"]') && $(window).width() >= 992) || (content.is('[class*="col-lg"]') && $(window).width() >= 1440)) {
if (!content.hasClass('fixed')) {
content.addClass('fixed');
$('.content-fix-wrap', content).scrollTop(0);
};
if (footerOffset != 0 && footerOffset <= scrolled) {
$('.content-fix-inner', content).css('padding-bottom', (scrolled - footerOffset + contentPadding));
};
};
} else {
content.removeClass('fixed');
$('.content-fix-inner', content).css('padding-bottom', '');
}
}
// fixed left/right hand side column padding bottom and width
function contentFixPushCal() {
$('.content-fix-scroll').each(function(index) {
$(this).css('width', $(this).closest('.content-fix').outerWidth());
$('.content-fix-inner', $(this)).css('width', $(this).closest('.content-fix').width());
});
if ($('.footer').length) {
footerOffset = $('.footer').offset().top;
};
}