I have a javascript code to rotate several divs using the .fadeOut .fadeIn functions and I have those same divs float on the sidebar so the position stays fixed while you scroll. This works perfectly when the window is larger than 980px but starts to overlap when on mobile devices. I was wondering if someone would be able to help me out with a code to have the the scroll function not run when the window is less than 980px. Below is the script i am using to fix the sidebar while scrolling.
$(function(){
var stickyRibbonTop = $('.rotate').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyRibbonTop ) {
$('.rotate').css({position: 'fixed', top: '0px'});
} else {
$('.rotate').css({position: 'relative'});
}
});
});
The test site is am using is beta.badsentinel.com. Please check and shrink the window size to get a better idea of what i am talking about. The sidebar will start to overlap.
thanks in advance.
if(document.body.clientWidth > 980)return;should work