-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp1.js
126 lines (104 loc) · 3.8 KB
/
app1.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
125
126
// let typed; // Declare typed variable outside for access in other functions
// function startTyping() {
// typed = new Typed(".typing", {
// strings: ["","Alvas Singari Melam","അൽവാസ് ശിങ്കാരിമേളം","ಆಳ್ವಾಸ್ ಸಿಂಗಾರಿ ಮೇಳ","अल्वास् सिंगारि मेलम्"],
// typeSpeed: 100, // Typing speed
// backSpeed: 150, // Backspacing speed
// backDelay: 1000, // Delay before starting to backspace
// startDelay: 400, // Delay before typing starts
// loop: true,
// showCursor: false,
// });
// }
// function stopTyping() {
// if (typed) {
// typed.destroy(); // Destroy the Typed instance to stop the animation
// }
// }
// function checkWindowSize() {
// if (window.innerWidth >= 400) {
// startTyping();
// } else {
// stopTyping();
// }
// }
// // Check window size on load
// checkWindowSize();
// // Add event listener for window resize
// window.addEventListener("resize", checkWindowSize);
let typed; // Declare typed variable outside for access in other functions
function startTyping() {
typed = new Typed(".typing", {
strings: ["", "Alva's Singari Melam"],
typeSpeed: 100, // Typing speed
backSpeed: 150, // Backspacing speed
backDelay: 1000, // Delay before starting to backspace
startDelay: 400, // Delay before typing starts
loop: true,
showCursor: false,
});
}
function stopTyping() {
if (typed) {
typed.destroy(); // Destroy the Typed instance to stop the animation
}
}
function checkWindowSize() {
const typingElement = document.querySelector(".typing");
if (window.innerWidth >= 400) {
startTyping();
} else {
stopTyping();
typingElement.textContent = "Alva's Singari Melam"; // Directly display text
}
}
// Check window size on load
window.onload = checkWindowSize;
// Add event listener for window resize
window.addEventListener("resize", checkWindowSize);
// aside
const nav = document.querySelector(".nav"),
navList = nav.querySelectorAll("li"),
totalNavList = navList.length,
allSection = document.querySelectorAll(".section"),
totalSection = allSection.length;
for(let i=0; i<totalNavList;i++){
const a = navList[i].querySelector("a");
a.addEventListener("click",()=>{
a.classList.remove("not-active")
for(let i=0;i<totalSection;i++){
allSection[i].classList.remove("back-section")
}
for(let j=0; j<totalNavList;j++){
if(navList[j].querySelector("a").classList.contains("active")){
allSection[j].classList.add("back-section");
}
navList[j].querySelector("a").classList.remove("active");
navList[j].querySelector("a").classList.add("not-active");
}
a.classList.add("active")
showSection(a)
if(window.innerWidth<1200){
asideSectionTogglerBtn()
}
})
}
function showSection(element){
for(let i=0;i<totalSection;i++){
allSection[i].classList.remove("active")
}
const target = element.getAttribute("href").split("#")[1]
document.querySelector("#"+target).classList.add("active")
}
const navTogglerBtn = document.querySelector(".nav-toggler"),
aside = document.querySelector(".aside");
navTogglerBtn.addEventListener("click",()=>{
asideSectionTogglerBtn();
})
function asideSectionTogglerBtn(){
aside.classList.toggle("open");
navTogglerBtn.classList.toggle("open");
for(let i=0; i<totalSection;i++){
allSection[i].classList.toggle("open");
}
}