1

I'm using this jQuery code to make a parallax effect when scrolling :

$(window).scroll(function() {
    var x = $(window).scrollTop();
        $('#header').css('background-position', 'center ' + parseInt(-x / 1) + 'px');
});

The problem is that my background image is at 300px from top of my window at start and with this code I can't set this origin position to start scrolling the background at 300px from top, the background-image jump directly to top:0px

And one another thing :

Is it possible to stop the effect if I reach a specific position (Example : If the background-position reach 300px just stop the movement)

Any ideas about it? Thanks!

4

0 回答 0