-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
124 lines (97 loc) · 3.77 KB
/
script.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/** SECTION ACCUEIL **************************************************/
/** Annimation des titres **/
let words = document.querySelectorAll(".word");
words.forEach((word)=>{
let letters = word.textContent.split("");
word.textContent="";
letters.forEach((letter)=>{
let span = document.createElement("span");
span.textContent = letter;
span.className = "letter";
word.append(span);
});
});
let currentWordIndex = 0;
let maxWordIndex = words.length -1;
words[currentWordIndex].style.opacity = "1";
let changeText = ()=>{
let currentWord = words[currentWordIndex];
let nextWord = currentWordIndex === maxWordIndex ? words[0] : words[currentWordIndex + 1];
Array.from(currentWord.children).forEach((letter,i)=>{
setTimeout(()=>{
letter.className = "letter out";
},i * 80);
});
nextWord.style.opacity="1";
Array.from(nextWord.children).forEach((letter,i)=>{
letter.className = "letter behind";
setTimeout(()=>{
letter.className = "letter in";
},340 + i * 80);
});
currentWordIndex = currentWordIndex === maxWordIndex ? 0 : currentWordIndex + 1;
};
changeText();
setInterval(changeText,3000);
// Cercles de compétences Pro ////////////////////////////////////////////::
const circles = document.querySelectorAll('.circle');
circles.forEach(elem=>{
var dots = elem.getAttribute("data-dots");
var marked = elem.getAttribute("data-parcent");
var percent = Math.floor(dots*marked/100);
var points = "";
var rotate = 360/dots;
for(let i = 0 ; i < dots ; i++){
points += `<div class="points" style="--i:${i}; --rot:${rotate}deg"></div>`;
}
elem.innerHTML= points;
const pointsMarked = elem.querySelectorAll('.points');
for (let i = 0; i<percent ;i++){
pointsMarked[i].classList.add('marked')
};
})
// mix it up SECTION PORTFOLIO -----------------------------------------------------------------------------------------------//
var mixer = mixitup('.portfolio-gallery');
/** ACTIVATION DES MENUS **************************************************/
let menuLi = document.querySelectorAll('header ul li a');
let section = document.querySelectorAll('section');
function activeMenu(){
let len = section.length;
while(--len && window.scrollY + 97 < section[len].offsetTop){}
menuLi.forEach(sec => sec.classList.remove("active"));
menuLi[len].classList.add("active");
}
activeMenu();
window.addEventListener("scroll", activeMenu);
/*====================== Sticky navbar ============================= */
const header = document.querySelectorAll("header");
window.addEventListener("scroll",function(){
header.classList.toggle("sticky",window.scrollY > 50)
})
/*====================== toggle icon navbar ============================= */
let menuIcon = document.querySelector("#menu-icon");
let navlist = document.querySelector(".navlist");
menuIcon.onclick = ()=>{
menuIcon.classList.toggle("bx-x");
navlist.classList.toggle("open");
}
window.onscroll = ()=>{
menuIcon.classList.remove("bx-x");
navlist.classList.remove("open");
}
/*====================== parallax ============================= */
const observer = new IntersectionObserver((entries)=>{
entries.forEach((entry)=> {
if(entry.isIntersecting){
entry.target.classList.add("show-items");
}else{
entry.target.classList.remove("show-items");
}
});
});
const scrollScale = document.querySelectorAll(".scroll-scale");
scrollScale.forEach((el)=>observer.observe(el));
const scrollBottom = document.querySelectorAll(".scroll-bottom");
scrollBottom.forEach((el)=>observer.observe(el));
const scrollTop = document.querySelectorAll(".scroll-top");
scrollTop.forEach((el)=>observer.observe(el));