Commit 0ccf711c by Hasnain

WL-890 | Fix the course detail page sticky bar.

parent 0c73c8f6
...@@ -9,45 +9,45 @@ $(document).ready(function() { ...@@ -9,45 +9,45 @@ $(document).ready(function() {
'use strict'; 'use strict';
var makeSticky = function() { var makeSticky = function() {
$el.css({ $el.css({
position: 'fixed', 'position': 'fixed',
top: 0, 'top': 0,
width: '100%', 'width': '100%',
'z-index': '10', 'z-index': '10',
'box-shadow': '0px 1px 5px rgba(0,0,0,0.5)' 'box-shadow': '0px 1px 5px rgba(0,0,0,0.5)'
}); });
$('.sticky-course-title').removeClass('hidden'); $(".sticky-course-title").removeClass("hidden");
$('.course-run').addClass('hidden'); $(".course-run").addClass("hidden");
}; };
var removeSticky = function() { var removeSticky = function() {
$el.css({ $el.css({
position: 'static', 'position': 'static',
'z-index': '0', 'z-index': '0',
'box-shadow': 'none' 'box-shadow': 'none'
}); });
$('.sticky-course-title').addClass('hidden'); $(".sticky-course-title").addClass("hidden");
$('.course-run').removeClass('hidden'); $(".course-run").removeClass("hidden");
}; };
var initializeSticky = function() { var initializeSticky = function() {
var windowTop = ''; var windowTop = '';
if ($el.length) { // Element should exist if ($(window).width() >= MIN_WEB_WIDTH){
$(window).scroll(function() { windowTop = $(window).scrollTop();
if ($(window).width() >= MIN_WEB_WIDTH) { if (stickyBarTop < windowTop){
windowTop = $(window).scrollTop(); makeSticky();
if (stickyBarTop < windowTop) { }
makeSticky(); else {
} else { removeSticky();
removeSticky(); }
}
}
});
} }
}; else {
initializeSticky();
$(window).resize(function() {
if ($(window).width() >= MIN_WEB_WIDTH) {
makeSticky();
} else {
removeSticky(); removeSticky();
} }
};
if ($el.length) { //Element should exist
$(window).scroll(function(){
initializeSticky();
});
}
$(window).resize(function() {
initializeSticky()
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment