jQuery(function ($) {
$(window).scroll(function() {
var y = $(this).scrollTop();
if (y > 360) {
var pos_yvalue = y - 294;
$('.site-header .wrap').css('background-position-y',
pos_yvalue.toString() + 'px');
}
});
});
With above I want to set an image in the wrap-header (.site-header .wrap
) to a background-position-y relative to the y-position of the scroll.
So when I scroll above 360px then I want to position the background-image of site-header .wrap to be 66 and when it is 362 the background-image of the wrap should be 65 etc.
Above code would represent the values 66, 67, 68 etc instead of counting downwards like this: 66, 65, 64, 63,62,61 etc..
For some reason I can't get my head around this one.