-
Notifications
You must be signed in to change notification settings - Fork 0
/
resume_js_file.js
60 lines (57 loc) · 1.69 KB
/
resume_js_file.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
// var setcounter = 0;
// function scroolvertically(){
// }
var select = document.querySelectorAll('#body-nav a');
for(var i =0 ;i<select.length; i++){
select[i].addEventListener('click',function(event){
event.preventDefault();
var elementid = this.textContent.trim().toLowerCase();
var ele = document.getElementById(elementid);
var interval = setInterval(function(){
var coor = ele.getBoundingClientRect();
if(coor.top <=0){
clearInterval(interval);
return;
}
window.scrollBy(0,50);
}, 50);
});
}
// var a = document.querySelectorAll('');
var cl = document.querySelectorAll('#skill-des > div');
var tl = document.getElementById('skill-des');
window.addEventListener('scroll',checkscroll);
var checkanimation = false;
function intialising(){
for(let bar of cl){
bar.style.width = 0 + '%';
}
}
intialising();
function fillbar(){
for(let bar of cl){
let targetwidth = bar.getAttribute('data-value');
let current = 0;
let interval = setInterval(function(){
// var cordinate = bar.getBoundingClientRect();
if(current>targetwidth){
clearInterval(interval);
return;
}
current++;
bar.style.width = current + '%';
},5);
}
}
function checkscroll(){
var coor = tl.getBoundingClientRect();
if(!checkanimation && coor.top <= window.innerHeight ){
checkanimation = true;
console.log('hello!');
fillbar();
}
else if(coor.top > window.innerHeight){
checkanimation = false;
intialising();
}
}