-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
216 lines (151 loc) · 5.29 KB
/
script.js
File metadata and controls
216 lines (151 loc) · 5.29 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
let element = document.querySelectorAll(".heading");
let image = document.querySelectorAll("img");
element.forEach((elem) => {
elem.addEventListener("mousemove" , (dets) => {
if(image){
elem.childNodes[3].style.opacity = "1"
elem.childNodes[3].style.left = dets.clientX + "px";
}
})
elem.addEventListener("mouseleave" , () => {
elem.childNodes[3].style.opacity = "0"
})
})
//------------------------------------------------------------------------------------------------
const textContainer = document.querySelector(".designation");
// Define the text to animate
const text = "Hello, World! This is an example.";
// GSAP timeline for text animation
const tl = gsap.timeline({ repeat: -1 });
// Function to animate text
function animateText() {
// Add text to timeline in reverse alphabetical order
tl.to(textContainer, {
duration: text.length * 0.1, // Adjust duration based on text length
text: {
value: 'Frontend Developer', // Start with empty text
scrambleText: {
text: text.split('').reverse().join(''), // Reverse the text alphabetically
chars: "visible", // Only reveal characters that are already displayed
speed: 0.3, // Typing speed (characters per second)
},
},
ease: "ease", // Linear ease
})
.to(textContainer, {
duration: text.length * 0.1, // Adjust duration based on text length
text: {
value: '', // Start with empty text
scrambleText: {
text: text,
chars: "visible", // Only reveal characters that are already displayed
speed: 0.1, // Typing speed (characters per second)
},
},
ease: "none", // Linear ease
});
}
// Initial call to start animation
animateText();
// Uncomment this line if you want to start the animation immediately
// tl.play();
//--------------------------------------------------------------------------------------------//
function copyEmailToClipboard() {
var emailToCopy = "sagarbisht409@gmail.com";
var textarea = document.createElement("textarea");
textarea.value = emailToCopy;
document.body.appendChild(textarea);
textarea.select();
textarea.setSelectionRange(0, textarea.value.length);
document.execCommand("copy");
document.body.removeChild(textarea);
alert("Email copied to clipboard: " + emailToCopy);
}
function copyphonenumberToClipboard() {
var emailToCopy = "8287325773";
var textarea = document.createElement("textarea");
textarea.value = emailToCopy;
document.body.appendChild(textarea);
textarea.select();
textarea.setSelectionRange(0, textarea.value.length);
document.execCommand("copy");
document.body.removeChild(textarea);
alert(`mobile number is ${emailToCopy}`);
}
// -------scroll bar and circular-fixed scroll bar---------------------------------------------------------
const circle = document.querySelector('.circular');
let totalScroll = 0;
function handleScroll() {
const currentScroll = window.scrollY;
const scrollDifference = currentScroll - totalScroll;
totalScroll += scrollDifference;
const rotationAngle = totalScroll;
gsap.to(circle, {
rotation: rotationAngle,
duration: 0,
ease: "none"
});
}
window.addEventListener('scroll', handleScroll);
//--------------------------------------------------------------------------------------------
document.addEventListener("DOMContentLoaded" , () => {
gsap.fromTo(".left", {
opacity: 0,
y: 100,
}, {
opacity: 1,
y: 0,
stagger: 0.2,
duration: 0.5,
});
gsap.fromTo(".circular", {
opacity: 0,
x: -100,
}, {
delay : 1.2,
opacity: 1,
x: 0,
stagger: 0.2,
duration: 0.5,
});
const cards = document.querySelectorAll('.card');
// Initialize Intersection Observer
const observer = new IntersectionObserver(entries => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
// Trigger GSAP animation for each card with a staggered delay
gsap.from(entry.target, {
y: 100,
opacity: 0,
duration: 2,
ease: "power2.out",
delay: index * 0.2 // Stagger delay based on index
});
// Unobserve the card after animating to prevent re-triggering
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.5 // Trigger when 50% of the card is visible
});
// Observe each card
cards.forEach(card => {
observer.observe(card);
});
})
gsap.fromTo(".my-image", {
opacity: 0,
y: 100,
}, {
delay : 0.7,
opacity: 1,
y: 0,
duration: 0.5,
});
//mouse ---------------------------------------------------------------------------
document.querySelector("#hamburger").addEventListener("click" , () => {
document.querySelector(".hamburger-responsive").style.right = "0"
})
document.querySelector(".cross").addEventListener("click" , () => {
document.querySelector(".hamburger-responsive").style.right = "-300px"
})