forked from akshitagupta15june/Moksh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
71 lines (61 loc) · 2.23 KB
/
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
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
function googleTranslateElementInit ()
{
new google.translate.TranslateElement(
{ pageLanguage: 'en' },
'google_translate_element'
)
}
let dropMenuLinks = document.querySelector( '.dropMenuLinks' ),
indexOpenDropDown = document.querySelector( '.indexOpenDropDown' ),
indexNavbar = document.querySelector( '.indexNavbar' ),
cardAr = document.querySelector( '.cardAr' ),
cardIskon = document.querySelector( '.cardIskon' ),
cardStory = document.querySelector( '.cardStory' ),
cardClock = document.querySelector( '.cardClock' ),
cardShlok = document.querySelector( '.cardShlok' ),
contentWrapper = document.querySelector( '.contentWrapper' ),
cardRejuvenate = document.querySelector( '.cardRejuvenate' )
contentWrapper.onscroll = () =>
{
contentWrapper.scrollTop > 5 ? indexNavbar.classList.add( 'bg-slate-900', 'shadow-2xl' ) : indexNavbar.classList.remove( 'bg-slate-900', 'shadow-2xl' )
contentWrapper.scrollTop > 1100 ? cardAr.classList.add( 'right-0' ) : ''
contentWrapper.scrollTop > 1600 ? cardIskon.classList.add( 'left-0' ) : ''
contentWrapper.scrollTop > 2300 ? cardStory.classList.add( 'right-0' ) : ''
contentWrapper.scrollTop > 3100 ? cardClock.classList.add( 'left-0' ) : ''
contentWrapper.scrollTop > 3850 ? cardShlok.classList.add( 'right-0' ) : ''
contentWrapper.scrollTop > 4500 ? cardRejuvenate.classList.add( 'left-0' ) : ''
}
indexOpenDropDown.onclick = () =>
{
dropMenuLinks.style.right = 0
}
let closeDropDown = document.querySelector( ".closeDropDown" )
closeDropDown.onclick = () =>
{
dropMenuLinks.style.right = '-2000px'
}
// Ends all pages menu interaction
// 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 );