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

286
Visualizações
Smooth scroll when setting CSS element in jQuery

I'm dynamically setting some CSS attributes on an element in jQuery and it seems like the animation is quite choppy and detracts from the user experience:

enter image description here

This is the code where I set the CSS attributes via jQuery:

  updateValue = _.debounce(() => {
    var scroll = $(window).scrollTop();
    $("#tableBody").css("visibility", "hidden");

    if ($("#div1").offset() && scroll >= $("#div1").offset().top) {
      $("#idHeader tr th").css("top", scroll - $("#div1").offset().top - 10);
    } else {
      $("#idHeader tr th").css("top", 0);
    }

    $("#tableBody").css("visibility", "visible");
  }, 1);

  handleScroll = () => {
    this.updateValue();
  };

This is my HTML element:

  <div style={{ overflowX: "scroll" }}>
    <div id="div1" className="container">
      <table className="odds-table">
        <thead id="idHeader">
          <tr>
            <th style={{ padding: 10 }}></th>
            {this.renderSportsbooks(marketOdds)}
          </tr>
        </thead>
        <tbody id="tableBody">{this.renderOdds(marketOdds)}</tbody>
      </table>
    </div>
  </div>

How can I get the element to scroll to be less choppy?

about 4 years ago · Juan Pablo Isaza
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