-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
76 lines (68 loc) · 2.05 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
//validação formulário de contato
const telefone = document.getElementById('input-fone')
telefone.addEventListener('keypress', () => {
let inputlength = telefone.value.length
if (inputlength === 0){
telefone.value='('
}
if (inputlength === 3){
telefone.value+=') '
}
if (inputlength === 10){
telefone.value+='-'
}
})
document.getElementById("input-name").addEventListener("keypress", function(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode < 65 || (charCode > 90 && charCode < 97) || charCode > 122) && charCode !== 32)
evt.preventDefault();
});
document.getElementById("input-fone").addEventListener("keypress", function(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
evt.preventDefault();
});
//FIM validação formulário de contato
//Menu responsivo
const Menu = document.querySelector('.menu')
const Bar = document.querySelector('.nav-menu')
Menu.addEventListener('click', () => {
Menu.classList.toggle('ativo')
Bar.classList.toggle('ativo')
})
document.querySelectorAll('a').forEach(a => {
a.addEventListener('click', () => {
Menu.classList.remove('ativo');
Bar.classList.remove('ativo');
});
});
//FIM menu responsivo
//Slider de projetos
const slider = document.querySelector('.slider');
const slides = document.querySelectorAll('.projects-img');
const prevBtn = document.querySelector('#btn-back');
const nextBtn = document.querySelector('#btn-next');
let slideIndex = 0;
function showSlide(n) {
slides.forEach(slide => {
slide.style.transform = `translateX(-${n * 100}%)`;
slide.style.transition = 'transform 1s ease-in-out';
});
}
function nextSlide() {
slideIndex++;
if (slideIndex > slides.length - 1) {
slideIndex = 0;
}
showSlide(slideIndex);
}
function prevSlide() {
slideIndex--;
if (slideIndex < 0) {
slideIndex = slides.length - 1;
}
showSlide(slideIndex);
}
nextBtn.addEventListener('click', nextSlide);
prevBtn.addEventListener('click', prevSlide);
//FIM slider projetos