-
Notifications
You must be signed in to change notification settings - Fork 1
/
Homepage.js
67 lines (56 loc) · 1.36 KB
/
Homepage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//#region Barre de navigation
//http://jsfiddle.net/AUsnL/
var header = document.querySelector("#Wrapper header");
function scrolled()
{
var windowHeight = document.body.clientHeight, currentScroll = document.body.scrollTop || document.documentElement.scrollTop;
header.className = (currentScroll >= windowHeight - header.offsetHeight) ? "fixed" : "";
}
addEventListener("scroll", scrolled, false);
//#endregion
//#region Carrousel
let indexImage = 1;
slideImg(indexImage);
function maBoucle()
{
setTimeout(function()
{
slideImg(indexImage += 1);
console.log("OUI")
maBoucle(); // relance la fonction
}, 6000);
}
maBoucle(); // on n’oublie pas de lancer la fonction une première fois
function defilement(n)
{
slideImg(indexImage += n);
}
function image(n)
{
slideImg(indexImage = n);
}
function slideImg(n)
{
let i;
let carrousel = document.getElementsByClassName("Carrousel");
let points = document.getElementsByClassName("Point");
if (n > carrousel.length)
{
indexImage = 1;
}
if (n < 1)
{
indexImage = carrousel.length;
}
for (i = 0; i < carrousel.length; i++)
{
carrousel[i].style.display = "none";
}
for (i = 0; i < points.length; i++)
{
points[i].className = points[i].className.replace(" active", "");
}
carrousel[indexImage-1].style.display = "block";
points[indexImage-1].className += " active";
}
//#endregion