-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
151 lines (119 loc) · 4.17 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
document.addEventListener('DOMContentLoaded', function () {
const scrollLinks = document.querySelectorAll('.navbar-nav a');
scrollLinks.forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetId);
window.scrollTo({
top: targetSection.offsetTop - 70,
behavior: 'smooth'
});
});
});
});
window.addEventListener('DOMContentLoaded', function() {
var portfolio = document.getElementById('portfolio');
portfolio.addEventListener('wheel', function(event) {
event.preventDefault();
var delta = event.deltaY || event.detail || event.wheelDelta;
portfolio.scrollTop += delta;
});
});
(function() {
'use strict';
// Définir les variables
var timelines = document.querySelectorAll('.timeline2');
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
function callbackFunc() {
timelines.forEach(function(timeline) {
var parentRect = timeline.getBoundingClientRect();
var items = timeline.querySelectorAll("li");
items.forEach(function(li) {
var rect = li.getBoundingClientRect();
if (rect.bottom <= (parentRect.top + (rect.height / 2)) || rect.top >= (parentRect.bottom - (rect.height / 2))) {
li.classList.remove("in-view");
} else {
li.classList.add("in-view");
}
});
});
}
var updateLayout = debounce(function() {
callbackFunc();
}, 500);
window.addEventListener("load", callbackFunc);
window.addEventListener("resize", updateLayout);
window.addEventListener("scroll", callbackFunc);
timelines.forEach(function(timeline) {
timeline.addEventListener("scroll", callbackFunc);
});
})();
document.addEventListener('DOMContentLoaded', () => {
const filterButtons = document.querySelectorAll('.filter-btn');
const galleryItems = document.querySelectorAll('.gallery-item');
filterButtons.forEach(button => {
button.addEventListener('click', () => {
filterButtons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
const category = button.getAttribute('data-category');
galleryItems.forEach(item => {
const itemCategory = item.getAttribute('data-category');
if (category === 'all' || itemCategory === category) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
});
document.querySelector('.filter-btn.active').click();
});
document.querySelectorAll('.category-title').forEach(title => {
title.addEventListener('click', () => {
const category = title.parentElement;
if (category.classList.contains('open')) {
category.classList.remove('open');
} else {
document.querySelectorAll('.competence-category').forEach(c => c.classList.remove('open'));
category.classList.add('open');
}
});
});
// Fonction pour taper le texte lettre par lettre
document.addEventListener("DOMContentLoaded", () => {
const firstName = "Laura Miguel";
const typingSpeed = 100;
typeText("typed-name", firstName, typingSpeed);
});
function typeText(elementId, text, speed) {
let i = 0;
const element = document.getElementById(elementId);
function typeWriter() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
typeWriter();
}
const toggle = document.getElementById("navbar-toggle");
const menu = document.getElementById("navbar-menu");
toggle.addEventListener("click", () => {
toggle.classList.toggle("active");
menu.classList.toggle("active");
});