forked from akshitagupta15june/Moksh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (26 loc) · 798 Bytes
/
script.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
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{pageLanguage: 'en'},
'google_translate_element'
);
}
// Get the "return to top" button element
let returnToTopButton = document.getElementById('returnToTop');
// Function to scroll to the top of the page
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Function to toggle the visibility of the "return to top" button
function toggleReturnToTopButton() {
if (window.scrollY > 200) {
returnToTopButton.classList.add('active');
} else {
returnToTopButton.classList.remove('active');
}
}
// Add event listeners
window.addEventListener('scroll', toggleReturnToTopButton);
returnToTopButton.addEventListener('click', scrollToTop);