-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (28 loc) · 978 Bytes
/
script.js
File metadata and controls
35 lines (28 loc) · 978 Bytes
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
function toggleMode() {
const html = document.documentElement
html.classList.toggle("light")
// pegar a tag img
const img = document.querySelector("#profile img")
// substituir a imagem
if(html.classList.contains('light')) {
// se tiver ligth mode on, adicionar a imagem light
img.setAttribute('src', './imagens/avatar-light-mode.png')
} else {
// se tiver dark mode on, adicionar imagem dark
img.setAttribute('src', './imagens/Avatar.png')
}
}
document.addEventListener('DOMContentLoaded', function() {
var btn = document.querySelector('.btn');
var initialLeft = btn.style.left;
var isRight = false;
btn.addEventListener('click', function() {
if (isRight) {
btn.style.left = initialLeft;
isRight = false;
} else {
btn.style.left = '32px'; /* Altere o valor para controlar a distância do deslizamento */
isRight = true;
}
});
});