I want to fix a div during scrolling of the page. My code works in desktop browsers but it is not working in mobile devices where the div is fixed only when the scroll bar stops. You can test the page here www.spiaggiati.it/antani/.
The code is:
function fixDiv() {
var $div = $("#order");
if ($(window).scrollTop() > $div.data("top")) {
$div.css({'position': 'fixed', 'top': '-10px', 'width': $('div#content').width()});
$('#categories').css('margin-top', '50px');
}
else {
$div.css({'position': 'static', 'top': 'auto'});
$('#categories').css('margin-top', '0px');
}
}