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

183
Visualizações
Accurately detect if a browser supports smooth scrolling?

Now that Safari 15.4 now supports native smooth scrolling, I am looking for a reliable way to check if a browser uses native smooth scrolling.

I have tried this method:

if (getComputedStyle(document.body).scrollBehavior === 'smooth') {
    console.log('Smooth scrolling natively supported ');
}else{
    console.log('Smooth scrolling NOT natively supported');
}

But it doesn't accurately detect smooth scrolling on Chrome and Safari 15.4 (it's returning a false negative). This is because scrollBehavior is set to auto.

I have also tried this method:

let supported = 'scrollBehavior' in document.documentElement.style;
if(supported == true){
    console.log('Smooth scrolling natively supported ');
}else{
    console.log('Smooth scrolling NOT natively supported');
}

Which seems to be more reliable, but when I disable smooth scrolling on Google Chrome, it reads a false positive. Could this possibly be because the browser supports it, but it is just not enabled? (I disabled it by starting Chrome from terminal using /Applications/Google\ Chrome.app --args --disable-smooth-scrolling)

What is the best method for checking is smooth scrolling is natively supported by a browser? Does anyone have an older version (pre v61) that they can test these on or other browsers that don't natively support smooth scrolling?

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

0

The most native way to do this would be to use the @supports CSS at-rule to check for browser support:

@supports (scroll-behavior:smooth) {
    /* Supports smooth scrolling */
}

To do this check in JavaScript, you may use this function on the CSS object:

if(window.CSS.supports('scroll-behavior', 'smooth')) {
    // Supports smooth scrolling
}
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