Skip to content

Commit 6b86f9c

Browse files
Update script.js
1 parent 6c9ccf6 commit 6b86f9c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

script.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Configurações iniciais
2-
document.addEventListener('DOMContentLoaded', () => {
3-
// 1. Scroll suave para seções
4-
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
2+
ocument.querySelectorAll('a[href^="#"]').forEach(anchor => {
53
anchor.addEventListener('click', function(e) {
64
e.preventDefault();
75
const target = document.querySelector(this.getAttribute('href'));
86
if (target) {
9-
const offset = 100; // Compensação para a nav fixa
10-
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - offset;
7+
const headerHeight = document.querySelector('.nav-termos').offsetHeight;
8+
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - headerHeight;
119

1210
window.scrollTo({
1311
top: targetPosition,
@@ -17,7 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {
1715
});
1816
});
1917

20-
// 2. Destaque dinâmico de seções
18+
// 2. Destaque dinâmico de seções
2119
const observerOptions = {
2220
threshold: 0.1,
2321
rootMargin: '0px'
@@ -35,7 +33,7 @@ document.addEventListener('DOMContentLoaded', () => {
3533
observer.observe(section);
3634
});
3735

38-
// 3. Botão "Voltar ao Topo"
36+
// 3. Botão "Voltar ao Topo"
3937
const backToTop = document.createElement('button');
4038
backToTop.innerHTML = '↑';
4139
backToTop.className = 'back-to-top';
@@ -53,13 +51,13 @@ document.addEventListener('DOMContentLoaded', () => {
5351
backToTop.style.display = (window.scrollY > 500) ? 'block' : 'none';
5452
});
5553

56-
// 4. Data da última atualização
54+
// 4. Data da última atualização
5755
const lastUpdated = document.createElement('p');
5856
lastUpdated.className = 'ultima-atualizacao';
5957
lastUpdated.innerHTML = `Última atualização: ${new Date(document.lastModified).toLocaleDateString('pt-BR')}`;
6058
document.querySelector('section[aria-labelledby="atualizacoes"]').appendChild(lastUpdated);
6159

62-
// 5. Interação com links de contato
60+
// 5. Interação com links de contato
6361
document.querySelectorAll('address a').forEach(link => {
6462
link.addEventListener('click', (e) => {
6563
if (!confirm('Você está sendo redirecionado para um recurso externo. Continuar?')) {

0 commit comments

Comments
 (0)