0

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');
}
}
Adrian P
  • 6,479
  • 4
  • 38
  • 55
qwerty
  • 227
  • 1
  • 2
  • 10

1 Answers1

0

I assume fixDiv() is fired constantly using the scroll-event.

If so then there's no solution at the moment as this is how scrolling on mobile devices works. The scroll event is triggered only when the scrolling has come to an end. As long as the momentum is moving the content no events are fired at all. You can see this in Figure 6-1 The panning gesture in Apple's "Safari Web Content Guide".

insertusernamehere
  • 23,204
  • 9
  • 87
  • 126