-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (42 loc) · 1.35 KB
/
Copy pathscript.js
File metadata and controls
48 lines (42 loc) · 1.35 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
47
48
$(document).ready(function() {
function sidebarScroll(){
var tmpWindow = $(window);
var wrapper = $('.main').height();
var content = $('.content').outerHeight();
var header = $('header').height();
var sidebar = $('#sidebar');
var offsetTop;
var offsetBottom;
if ( sidebar )
{
var sidebarOffset = sidebar.offset();
if ( sidebarOffset )
{
offsetTop = sidebarOffset.top;
tmpWindow.scroll( function(){
var sidebarWithpadding = sidebar.height() + 35;
offsetBottom = (wrapper + header) - sidebarWithpadding;
if ( tmpWindow.scrollTop() < offsetTop )
{
sidebar.removeClass('fixed bottom');
}
else if ( tmpWindow.scrollTop() > offsetBottom )
{
sidebar.removeClass('fixed').addClass('bottom');
}
else
{
sidebar.removeClass('bottom').addClass('fixed');
}
// For when the post content is smaller than the sidebar
if ( content < 1500 )
{
sidebar.addClass('small');
}
}
);
}
}
}
sidebarScroll();
});