-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
169 lines (148 loc) · 4.59 KB
/
Copy pathscript.js
File metadata and controls
169 lines (148 loc) · 4.59 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
document.addEventListener('DOMContentLoaded', function() {
// Get elements
const menuBar = document.getElementById('menuBar');
const closeMenu = document.getElementById('closeMenu');
const menuItems = document.getElementById('menu-items');
const logo = document.querySelector('.logo'); // Adjust if necessary
// Toggle Menu Function
function ToggleMenu() {
document.body.classList.toggle('menu-open');
menuItems.classList.toggle('open'); // Toggle the 'open' class on menu items
// Toggle visibility of menu bar and close icon
if (menuItems.classList.contains('open')) {
menuBar.style.display = 'none';
closeMenu.style.display = 'block';
closeMenu.style.zIndex = '9990000000000000000';
} else {
menuBar.style.display = 'block';
closeMenu.style.display = 'none';
}
logo.style.display = 'block'; // Ensure logo is visible
logo.style.zIndex = '10000000000';
}
// Close the menu when clicking outside of it
function closeMenuOnClickOutside(event) {
if (document.body.classList.contains('menu-open') &&
!menuItems.contains(event.target) &&
!menuBar.contains(event.target) &&
!closeMenu.contains(event.target) &&
!logo.contains(event.target)) {
ToggleMenu();
}
}
function setupMenu() {
// Add event listeners if viewport height is 750px or less
if (window.innerHeight <= 1050) {
menuBar.addEventListener('click', ToggleMenu);
closeMenu.addEventListener('click', ToggleMenu);
document.addEventListener('click', closeMenuOnClickOutside);
} else {
// Remove event listeners if viewport height is more than 750px
menuBar.removeEventListener('click', ToggleMenu);
closeMenu.removeEventListener('click', ToggleMenu);
document.removeEventListener('click', closeMenuOnClickOutside);
}
}
// Initial setup
setupMenu();
// Update setup on resize
window.addEventListener('resize', setupMenu);
});
// Typed.js Configuration (no changes needed here)
var typed = new Typed(".text", {
strings: ["Web Developer", "Graphic Designer", "UI/UX Designer", "Digital Marketer"],
typeSpeed: 150,
backSpeed: 150,
loop: true
});
// Page Loader Logic
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener("load", function() {
const loader = document.getElementById('loader');
loader.style.display = 'none';
const content = document.querySelector('.content');
content.style.display = 'block';
});
});
// Scroll-Based Icon Position Update
window.addEventListener('scroll', updateIconPosition);
window.addEventListener('load', updateIconPosition);
function updateIconPosition() {
const buttonContainer = document.querySelector('.navigator');
const icon = buttonContainer.querySelector('i');
if (!buttonContainer || !icon) return; // Ensure elements exist
const documentHeight = document.documentElement.scrollHeight;
const viewportHeight = window.innerHeight;
const scrollPosition = window.scrollY;
const scrollPercentage = (scrollPosition / (documentHeight - viewportHeight)) * 100;
const containerHeight = buttonContainer.offsetHeight;
const iconHeight = icon.offsetHeight;
const maxPosition = containerHeight - iconHeight;
const newPosition = (scrollPercentage / 100) * maxPosition;
icon.style.top = `${newPosition}px`;
}
/*Scroll Animation*/
document.addEventListener("DOMContentLoaded", function() {
gsap.registerPlugin(ScrollTrigger);
gsap.utils.toArray('.fade-in-up-target').forEach(el => {
gsap.fromTo(el,
{ opacity: 0, filter: blur(5), y: 50 },
{
opacity: 1,
filter: blur(0),
y: 0,
duration: 2,
scrollTrigger: {
trigger: el,
start: 'top 95%',
end: 'bottom 50%',
scrub: true
}
}
);
});
gsap.utils.toArray('.fade-in-left-target').forEach(el => {
gsap.fromTo(el,
{ opacity: 0, x: -100 }, // Start state
{
opacity: 1,
x: 0, // End state
duration: 2,
scrollTrigger: {
trigger: el,
start: 'top 98%',
end: 'bottom 50%',
scrub: true
}
}
);
});
gsap.utils.toArray('.fade-in-right-target').forEach(el => {
gsap.fromTo(el,
{ opacity: 0},
{
opacity: 1,
duration: 2,
scrollTrigger: {
trigger: el,
start: 'top 95%',
end: 'bottom 10%',
scrub: true
}
}
);
});
gsap.from(".line-2", {
scrollTrigger: {
trigger: ".orange",
scrub: true,
pin: true,
start: "top top",
end: "+=100%"
},
scaleX: 0,
transformOrigin: "left center",
ease: "none"
});
});
/*Scroll Animation*/