Pergunta

I am using this code to do a vertical scroll, and it works fine:

$('.flapleftclass').css('top',(0+(scrolled*0.5))+'px');

It works because I am referencing to the top. This (below) works for horizontally, but '.flapleftclass' changes x-value to what screen size you have. What I need is to find the center of the screen (50%). Is that possible? (like put 50% instead of 960 (as it is right now))

$('.flapleftclass').css('left',(960+(scrolled*0.5))+'px');
Foi útil?

Solução

Thanks to Martin Carneys link I did a simple rewriting and it works:

$('.flapleftclass').css('left',($(window).width()/2+(scrolled*0.5))+'px');
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top