-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstickySlider.js
More file actions
170 lines (115 loc) · 4.24 KB
/
Copy pathstickySlider.js
File metadata and controls
170 lines (115 loc) · 4.24 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
$(document).ready(function(){
var stickyHeight = $('.sticky-scroll-box').height();
var boxHeight = $('#content').height();
if(stickyHeight < boxHeight){
<!-- start function -->
function resetValues(){
//$('div').removeAttr('style');
$('.list-view-box div:first-child').removeAttr('style');
if(width > 767){
if(jQuery.support.leadingWhitespace == false){
}else {
var top = $('.sticky-scroll-box').offset().top;
var stickyHeight = $('.sticky-scroll-box').height();
var boxHeight = $('#content').height();
var bottom = $('.end-sticky').offset().top - stickyHeight;
$('.sticky-scroll-box').stop().removeClass('fixed absolute relative');
$('.fixed-side').removeAttr('style').css({"height": boxHeight + "px"});
$('.sticky-scroll-box').width($('.fixed-side').width());
$(window).scroll(function (event) {
var boxHeight = $('#content').height();
var y = $(this).scrollTop();
if (y >= top ){
$('.sticky-scroll-box').removeClass('absolute').addClass('fixed');
}else{
$('.sticky-scroll-box').removeClass('fixed').removeClass('absolute');
$('.sticky-scroll-box').width($('.fixed-side').width());
}
if (y >= bottom){
$('.sticky-scroll-box').removeClass('fixed').addClass('absolute');
$('.sticky-scroll-box').width($('.fixed-side').width());
}
});
}
} else {
var stickyHeight = $('.sticky-scroll-box').height();
$('.fixed-side').removeAttr('style').css({"height": stickyHeight + "px"});
$('.sticky-scroll-box').stop().removeClass('fixed absolute').addClass('relative');
}
};
// animate the sticky box if the screen size is larger then 767 px and not IE 8 //
function setSticky(){
if(width > 767){
if(jQuery.support.leadingWhitespace == false){
}else {
var top = $('.sticky-scroll-box').offset().top;
var stickyHeight = $('.sticky-scroll-box').height();
var boxHeight = $('#content').height();
var stickyHeight;
var bottom = $('.end-sticky').offset().top - stickyHeight;
$('.fixed-side').css({"height": boxHeight + "px"});
$('.sticky-scroll-box').width($('.fixed-side').width());
$(window).resize(function(){
var boxHeight = $('#content').height();
$('.fixed-side').css({"height": boxHeight + "px"});
$('.sticky-scroll-box').width($('.fixed-side').width());
});
$(window).scroll(function (event) {
var boxHeight = $('#content').height();
var y = $(this).scrollTop();
if (y >= top ){
$('.sticky-scroll-box').removeClass('absolute').addClass('fixed');
}else{
$('.sticky-scroll-box').removeClass('fixed absolute');
$('.sticky-scroll-box').width($('.fixed-side').width());
}
if (y >= bottom){
$('.sticky-scroll-box').removeClass('fixed').addClass('absolute');
$('.sticky-scroll-box').width($('.fixed-side').width());
}
});
}
}
} //end function
<!-- end function -->
var width = $(window).width();
$(window).resize(function(){
if($(this).width() != width){
width = $(this).width();
}
});
setSticky();
// create new height and reset code for sticky box on window resize
$(window).resize(function(){
resetValues();
});
//toggle switch code for calendar view && Resize the height of the sticky window if clicked on Calendar View
$('#toggle-switch').click(function(){
$('.list-view').toggle();
$('.large-calendar').toggle();
$(this).toggleClass('on');
setSticky();
});
$('#link-list-view').click(function(){
$('.large-calendar').hide();
$('.list-view').show();
$('#toggle-switch').removeClass('on');
resetValues();
});
$('#link-cal-view').click(function(){
$('.list-view').hide();
$('.large-calendar').show();
$('#toggle-switch').removeClass('on').addClass('on');
resetValues();
});
// hide calendar view on widow rezied
$(window).resize(function(){
$('.large-calendar').css('display','none');
$('.list-view').css('display', 'block');
$('#toggle-switch').removeClass('on');
});
}// END if(stickyHeight < boxHeight)
}); //end document ready
//Code if needed to run on ie8
//$('.fixed-side').css("width","25%");
//$('.fixed-side').css("height","500px");