main.js: fix scroll
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
6904171303
commit
486a8b6ba4
1 file changed
+9
-3
+9
-3
@@ -217,9 +217,15 @@
|
||||
|
||||
if (target) {
|
||||
e.preventDefault();
|
||||
target.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start'
|
||||
|
||||
// Calcular altura do header para ajustar o offset
|
||||
const headerHeight = elements.header ? elements.header.offsetHeight : 0;
|
||||
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset;
|
||||
const offsetPosition = targetPosition - headerHeight - 20; // 20px de margem extra
|
||||
|
||||
window.scrollTo({
|
||||
top: offsetPosition,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user