Bonjour,
j'ai utilisé le tutorial suivant pour faire un site avec un effet paralax jquery:
Cela fonctionne pas mal, mais il n'est pas tjs très ajusté car j'ai parfois un espace entre 2 images de fond si je redimensionne le navigateur.
http://www.ianlunn.co.uk/blog/code-t...orld-parallax/
Le point que je n'ai pas compris est le paramètre adjuster (ici 900 dans cet exemple):
je n'arrive pas a comprendre comment il est calculé dans l'exemple par rapport à la taille des images de fond ou des div.
Si quelqu'un a déjà utilisé cela ou a eu ce problème, merci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 if($firstBG.hasClass("inview")){ $firstBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 900, 0.3)}); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 //function that is called for every pixel the user scrolls. Determines the position of the background /*arguments: x = horizontal position of background windowHeight = height of the viewport pos = position of the scrollbar adjuster = adjust the position of the background inertia = how fast the background moves in relation to scrolling */ function newPos(x, windowHeight, pos, adjuster, inertia){ return x + "% " + (-((windowHeight + pos) - adjuster) * inertia) + "px"; }
Partager