I'm trying to create simple parallax effect changing backround position but the movement is not smooth in iOS Safari. Background changes its position only when I release touchscreen, but not when I scroll it.
Javascript:
$(window).bind('touchmove',function(e){
var scrolled = $(window).scrollTop();
$('#home').css('backgroundPosition', 'center ' + (0-(scrolled*2)) +'px');
});
It actually happens not only with chnaging backgroundPosition
, but also with top
for div element:
$('#home').css('top', (scrolled*2) +'px');
but at the same time margin-top
works fine and the movement is smooth.
What am I doing wrong and how can I make it work for iOS in the same way as mousewheel event?