-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscript.js
61 lines (52 loc) · 1.89 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
/*
Inspired by: "Login Page & Homepage"
By: Neo
Link: https://dribbble.com/shots/4485321-Login-Page-Homepage
*/
let usernameInput = document.querySelector('.username');
let passwordInput = document.querySelector('.password');
let showPasswordButton = document.querySelector('.password-button');
let face = document.querySelector('.face');
passwordInput.addEventListener('focus', event => {
document.querySelectorAll('.hand').forEach(hand => {
hand.classList.add('hide');
});
document.querySelector('.tongue').classList.remove('breath');
});
passwordInput.addEventListener('blur', event => {
document.querySelectorAll('.hand').forEach(hand => {
hand.classList.remove('hide');
hand.classList.remove('peek');
});
document.querySelector('.tongue').classList.add('breath');
});
usernameInput.addEventListener('focus', event => {
let length = Math.min(usernameInput.value.length - 16, 19);
document.querySelectorAll('.hand').forEach(hand => {
hand.classList.remove('hide');
hand.classList.remove('peek');
});
face.style.setProperty('--rotate-head', `${-length}deg`);
});
usernameInput.addEventListener('blur', event => {
face.style.setProperty('--rotate-head', '0deg');
});
usernameInput.addEventListener('input', _.throttle(event => {
let length = Math.min(event.target.value.length - 16, 19);
face.style.setProperty('--rotate-head', `${-length}deg`);
}, 100));
showPasswordButton.addEventListener('click', event => {
if (passwordInput.type === 'text') {
passwordInput.type = 'password';
document.querySelectorAll('.hand').forEach(hand => {
hand.classList.remove('peek');
hand.classList.add('hide');
});
} else {
passwordInput.type = 'text';
document.querySelectorAll('.hand').forEach(hand => {
hand.classList.remove('hide');
hand.classList.add('peek');
});
}
});