-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
101 lines (92 loc) · 2.88 KB
/
index.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
document.addEventListener("DOMContentLoaded", function () {
window.addEventListener("scroll", function () {
// sticky navbar on scroll script
if (window.scrollY > 20) {
document.querySelector(".navbar").classList.add("sticky");
} else {
document.querySelector(".navbar").classList.remove("sticky");
}
// scroll-up button show/hide script
if (window.scrollY > 500) {
document.querySelector(".scroll-up-btn").classList.add("show");
} else {
document.querySelector(".scroll-up-btn").classList.remove("show");
}
});
// slide-up script
document.querySelector(".scroll-up-btn").addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: "smooth" });
// removing smooth scroll on slide-up button click
document.querySelector("html").style.scrollBehavior = "auto";
});
document.querySelectorAll(".navbar .menu li a").forEach(function (element) {
// applying again smooth scroll on menu items click
element.addEventListener("click", function () {
document.querySelector("html").style.scrollBehavior = "smooth";
});
});
// toggle menu/navbar script
document.querySelector(".menu-btn").addEventListener("click", function () {
document.querySelector(".navbar .menu").classList.toggle("active");
document.querySelector(".menu-btn i").classList.toggle("active");
});
// typing text animation script
var typed = new Typed(".typing", {
strings: [
"Front end developer",
"Fresher",
"Technician",
"Blogger",
"Designer",
"Freelancer",
"Manager"
],
typeSpeed: 100,
backSpeed: 60,
loop: true
});
var typed2 = new Typed(".typing-3", {
strings: ["Connect with me on :)"],
typeSpeed: 100,
backSpeed: 60,
loop: true
});
var typed3 = new Typed(".typing-2", {
strings: [
"Front end developer",
"Fresher",
"Technician",
"Blogger",
"Designer",
"Freelancer",
"Manager"
],
typeSpeed: 100,
backSpeed: 60,
loop: true
});
// owl carousel script
var owlCarousel = new OwlCarousel({
margin: 20,
loop: true,
autoplay: true,
autoplayTimeout: 2000,
autoplayHoverPause: true,
responsive: {
0: {
items: 1,
nav: false
},
600: {
items: 2,
nav: false
},
1000: {
items: 3,
nav: false
}
}
});
// Replace ".carousel" with the appropriate selector for your carousel
owlCarousel.init();
});