-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-functions.js
35 lines (30 loc) · 1.03 KB
/
index-functions.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
//Botón scroll arriba
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
//formulario de contacto
const $form = document.querySelector('#form');
const $buttonMailTo = document.querySelector('#mail-to')
$form.addEventListener('submit', handleSubmit)
function handleSubmit(event) {
event.preventDefault()
const form = new FormData(this)
$buttonMailTo.setAttribute('href',
`mailto:ballian.eliana@gmail.com?subject= Nombre: ${form.get('name')} Correo: ${form.get('email')}&body=${form.get('message')}`
)
$buttonMailTo.click()
}
//scroll seccion nosotros
window.addEventListener('scroll', function () {
let nosotrosSection = document.getElementById('nosotros');
let scrollTopButton = document.querySelector('.scroll-top-button');
let nosotrosSectionPosition = nosotrosSection.getBoundingClientRect().top;
if (nosotrosSectionPosition <= 0) {
scrollTopButton.classList.add('show');
} else {
scrollTopButton.classList.remove('show');
}
});