Bonjour a tous
Je cherche à savoir si un element est visible a l'écran. L'objectif étant qu'a chaque fois que je scroll que je regarde si 10 elements de ma page apparaissent ou non a l'écran.
En cherchant sur le net j'ai trouvé un forum américain ou un membre avait posté une fonction mais ça ne fonctionne pas avec moi.
des idées ??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 var projets = new Array(); projets[0]="toto"; projets[1]="tata"; projets[2]="titi"; projets[3]="tutu"; window.onscroll = function (e) { for (var i = 0; i < projets.length; i++) { if (checkvisible($('#' + projets[i]))) { alert(projets[i]) + " est visible"); } } } function checkvisible( elm ) { var vpH = $(window).height(), // Viewport Height st = $(window).scrollTop(), // Scroll Top y = $(elm).offset().top; return (y > (vpH + st)); }
Partager