I have the following snippet which I want to disable on tablets and mobiles.
if ( !! $('#sidebar').offset()) {
var stickyTop = $('#sidebar').offset().top;
$(window).scroll(function() {
var windowTop = $(window).scrollTop();
if (stickyTop < windowTop) {
$('#sidebar').css({ position: 'fixed', top: "120px" , right: "5%" });
}
else {
$('#sidebar').css('position', 'static');
}
});
}
And I was thinking to wrap in inside a media query or something, like this:
if(@media (min-width:500px)){
if ( !! $('#sidebar').offset()) {
var stickyTop = $('#sidebar').offset().top;
$(window).scroll(function() {
var windowTop = $(window).scrollTop();
if (stickyTop < windowTop) {
$('#sidebar').css({ position: 'fixed', top: "120px" , right: "5%" });
}
else {
$('#sidebar').css('position', 'static');
}
});
}
}
But I'm sure that this wont work, so how would I stop this code from working on mobiles?