-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (30 loc) · 1.01 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
const SCROLL_TOP = document.querySelector('.scroll')
const YEAR = document.querySelector('.copyright span')
const EMAIL = document.querySelector('#email')
const REVERSE = document.querySelector('nav svg')
const HEIGHT = innerHeight
//condition to display scroll btn
document.addEventListener('scroll', () => {
if (scrollY >= HEIGHT * 2)
SCROLL_TOP.style.display = 'block'
else
SCROLL_TOP.style.display = 'none'
})
//scroll to top btn
SCROLL_TOP.addEventListener('click', () => {
scroll({
top: 0,
behavior: "smooth"
})
})
//add current year
YEAR.textContent = new Date().getFullYear()
//get the placeholder name@mail.com
let qualifiedName = EMAIL.getAttribute('placeholder')
EMAIL.addEventListener('focus', () => EMAIL.setAttribute('placeholder', ''))
EMAIL.addEventListener('blur', () => EMAIL.setAttribute('placeholder', qualifiedName))
//DARK / LIGHT mode
REVERSE.addEventListener('click', () => {
document.body.classList.toggle('reverse')
})
//TODO : add local storage