-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathapp.js
More file actions
95 lines (89 loc) · 3.19 KB
/
app.js
File metadata and controls
95 lines (89 loc) · 3.19 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
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
//Menu lateral
var menu_visible = false;
let menu = document.getElementById("nav");
function mostrarOcultarMenu(){
if(menu_visible==false){//si esta oculto
menu.style.display = "block";
menu_visible = true;
}
else{
menu.style.display = "none";
menu_visible = false;
}
}
//oculto el menu una vez que selecciono una opción
let links = document.querySelectorAll("nav a");
for(var x = 0; x <links.length;x++){
links[x].onclick = function(){
menu.style.display = "none";
menu_visible = false;
}
}
//Creo las barritas de una barra particular identificada por su id
function crearBarra(id_barra){
for(i=0;i<=16;i++){
let div = document.createElement("div");
div.className = "e";
id_barra.appendChild(div);
}
}
//selecciono todas las barras generales par aluego manipularlas
let html = document.getElementById("html");
crearBarra(html);
let javascript = document.getElementById("javascript");
crearBarra(javascript);
let wordpress = document.getElementById("wordpress");
crearBarra(wordpress);
let photoshop = document.getElementById("photoshop");
crearBarra(photoshop);
let php = document.getElementById("php");
crearBarra(php);
let ilustrator = document.getElementById("ilustrator");
crearBarra(ilustrator);
//Ahora voy a guardar la cantidad de barritas que se van a ir pintando por cada barar
//para eso utilizo un arreglo, cada posiciòn pertenece a un elemento
//comienzan en -1 porque no tiene ninguna pintada al iniciarse
let contadores = [-1,-1,-1,-1,-1,-1];
//esta variable la voy a utilizar de bandera para saber si ya ejecuto la animación
let entro = false;
//función que aplica las animaciones de la habilidades
function efectoHabilidades(){
var habilidades = document.getElementById("habilidades");
var distancia_skills = window.innerHeight - habilidades.getBoundingClientRect().top;
if(distancia_skills>=300 && entro==false){
entro = true;
const intervalHtml = setInterval(function(){
pintarBarra(html, 16, 0, intervalHtml);
},100);
const intervalJavascript = setInterval(function(){
pintarBarra(javascript, 11, 1, intervalJavascript);
},100);
const intervalWordpress = setInterval(function(){
pintarBarra(wordpress, 11, 2, intervalWordpress);
},100);
const intervalPhotoshop = setInterval(function(){
pintarBarra(photoshop, 15, 3, intervalPhotoshop);
},100);
const intervalPhp = setInterval(function(){
pintarBarra(php, 16, 4, intervalPhp);
},100);
const intervalIlustrator = setInterval(function(){
pintarBarra(ilustrator, 11, 5, intervalIlustrator);
},100);
}
}
//lleno una barra particular con la cantidad indicada
function pintarBarra(id_barra, cantidad, indice, interval){
contadores[indice]++;
x = contadores[indice];
if(x < cantidad){
let elementos = id_barra.getElementsByClassName("e");
elementos[x].style.backgroundColor = "#940253";
}else{
clearInterval(interval)
}
}
//detecto el scrolling del mouse para aplicar la animación de la barra
window.onscroll = function(){
efectoHabilidades();
}