-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
124 lines (103 loc) · 2.9 KB
/
app.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
const body=document.getElementsByTagName('body')[0]
const li=document.getElementsByTagName('li')
const nav=document.getElementById('nav')
const scrollBtn=document.getElementById('scroll')
const toggleButton = document.getElementsByClassName("toggle-button")[0]
const navbarLinks = document.getElementsByClassName("navbar-nav")[0]
const images = document.getElementsByClassName("image")
const tabBtns = document.getElementsByClassName("tab")
for (let index = 0; index < tabBtns.length; index++) {
const element = tabBtns[index];
element.addEventListener("click",()=>{
change(index)
})
}
toggleButton.addEventListener('click', () =>{
navbarLinks.classList.toggle('active')
toggleButton.classList.toggle('active')
})
function over(){
let text=document.getElementById('text')
let arr=['A Backend developer.','A Frontend developer.','A Kotlin developer.','A Competitive programmer','glad to meet you.']
arr.forEach(function (el, index) {
setTimeout(function () {
text.innerText=el
}, index * 1500);
});
}
function blink() {
let text=document.getElementById('text')
text.classList.toggle("blink")
}
setInterval(() => {
blink()
}, 1500);
window.onscroll=() => {
if (window.scrollY>=100){
scrollBtn.style.display='block'
}
else{
scrollBtn.style.display='none'
}
if (window.scrollY>=500){
if (!nav.classList.contains("bg")){
nav.classList.toggle('bg')
}
}
else{
if (nav.classList.contains("bg")) {
nav.classList.toggle("bg")
}
}
}
scrollBtn.addEventListener('click',()=>{
location.href='#'
})
let count = 0
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function prevSlide () {
if(count > 0) {
count--
change(count)
}
else{
count = images.length-1
change(count)
}
await sleep(2000)
}
async function nextSlide () {
if(count < images.length-1) {
count++
change(count)
}
else{
count = 0
change(count)
}
await sleep(2000)
}
var change = (count) =>{
for (let index = 0; index < images.length; index++) {
const element = images[index];
const btn = tabBtns[index];
if (element.classList.contains("active")){
element.classList.remove("active")
}
if (btn.classList.contains("active")){
btn.classList.remove("active")
}
}
let element=images[count]
let btn = tabBtns[count]
element.classList.toggle("active")
btn.classList.toggle("active")
}
document.getElementById("previous").onclick = prevSlide
document.getElementById("next").onclick = nextSlide
change(count)
setInterval(() => {
nextSlide()
}, 2000);