-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (59 loc) · 1.71 KB
/
Copy pathindex.js
File metadata and controls
69 lines (59 loc) · 1.71 KB
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
67
68
69
let lastScrollY = 0;
window.addEventListener("scroll", () => {
if (window.scrollY > lastScrollY) {
nav.style.top = "-80px";
} else {
nav.style.top = 0;
}
if (window.scrollY <= 120) {
nav.classList.add("top");
} else {
nav.classList.remove("top");
}
lastScrollY = window.scrollY;
});
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
console.log(entry);
if (entry.isIntersecting) {
entry.target.classList.add("scroll_show");
} else {
// entry.target.classList.remove(
// "scroll_show"
// ); /* Remet l'animation si le visiteur revient en haut puis en bas */
}
});
},
{
threshold: 0.25,
}
);
let hiddenElements = document.querySelectorAll(".scroll_hidden"),
animateTextElements = document.querySelectorAll(".text_fill");
hiddenElements.forEach((el) => observer.observe(el));
animateTextElements.forEach((el) => observer.observe(el));
// Code pour que l'étoile des boutons suive le curseur
// let followCursorElement = document.getElementById("caca");
// //Détecte si c'est une tablette/mobile
// function isTouchDevice() {
// try {
// document.createEvent("TouchEvent");
// return true;
// } catch (e) {
// return false;
// }
// }
// const move = (e) => {
// try {
// // PageX et PageY retournent la position du curseur
// var x = !isTouchDevice() ? e.pageX : e.touches[0].pageX;
// var y = !isTouchDevice() ? e.pageY : e.touches[0].pageY;
// } catch (e) {}
// followCursorElement.style.left = x + "px";
// followCursorElement.style.top = y + "px";
// };
// // Pour la souris
// document.addEventListener("mousemove", (e) => {
// move(e);
// });