Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
Smooth Scrolling with only vanilla JavaScript

I have always used this jQuery script for smooth scrolling:

var root = $('html, body');
$('a[href^="#"]').click(function() {
root.animate({
    scrollTop: $($.attr(this, 'href')).offset().top
}, 1000);
return false;
});

How can I do this with vanilla JavaScript? I have tried this:

document.querySelector(this.getAttribute('href')).scrollIntoView({
    behavior: 'smooth'
});

But it doesn't work with Safari, which is a deal breaker for me.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As you can read on the docs safari doesn't support options parameters on scrollIntoView so you'll need to find another method. I suggest taking a look at this alternative.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda