-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
74 lines (66 loc) · 1.87 KB
/
app.js
File metadata and controls
74 lines (66 loc) · 1.87 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
//code for smooth scroll
var navTags = document.querySelectorAll('.horizontal-list li a');
for(var i=0;i<navTags.length;++i)
{
navTags[i].addEventListener('click', function(event){
event.preventDefault();
var targetId= this.textContent.trim().toLowerCase();
var targetSection= document.getElementById(targetId);
if(targetSection!=null)
{
var interval = setInterval(function(){
var coordinates=targetSection.getBoundingClientRect();
if(coordinates.top <= 0)
{
clearInterval(interval);
return;
}
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight-100)
{
clearInterval(interval);
return;
}
window.scrollBy(0,5);
}, 2);
}
});
}
//code for skill bars filling
var bars = document.querySelectorAll('.skill div');
var skillSection = document.getElementById('skill-container');
window.addEventListener('scroll', checkScroll);
var check=false;
function initialFill(){
for(let bar of bars)
{
bar.style.width=0+'%';
}
}
initialFill();
function fillBars(){
for(let bar of bars)
{
let target= bar.getAttribute('bar-width');
let currWidth=0;
let interval=setInterval(function(){
if(currWidth>=target)
{
clearInterval(interval);
return;
}
++currWidth;
bar.style.width=currWidth+'%';
}, 25);
}
}
function checkScroll(){
if(skillSection.getBoundingClientRect().top < window.innerHeight && !check)
{
fillBars();
check=true;
}
if(skillSection.getBoundingClientRect().top > window.innerHeight)
{
check=false;
}
}