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

187
Visualizações
Element.scrollTop always return 0

I need to detect whether user scroll to the bottom of the HTML element. I know that best way to do that is use:

obj.scrollTop === (obj.scrollHeight - obj.offsetHeight)

But the problem is that in my case, obj.scrollTop always returns 0. It's probably something wrong with my CSS or with the fact that I use slick library, but I can't find what it could be.

Here's my parent component:

<div className="container container--light container--player">
    <Header menu="dark" />
    <main className="player">
        <div className="scrollCarousel">
            <Slider ref={slider} {...settings}>
                <PlayerSlide1 />
                <PlayerSlide2 />
                <PlayerFAQ ref={faqContainer} />
            </Slider>
        </div>
    </main>
</div>

And child component HTML:

<section className="faq scrollCarousel__slide" ref={ref}>
        ... some inner HTML
</section>

I want to detect whether user scroll to the bottom of my child component (with class faq).

Here's my CSS:

body {
    overflow: hidden;
    position: relative;
}

.container {
    overflow: hidden;
    height: 100vh
}

.player {
    position: relative;
    margin-top: 50px;
}

.scrollCarousel {
    width: 100%;
    height: auto;
    min-height: 75vh;
}

.scrollCarousel__slide {
    width: calc(var(--siteWidthNarrow) - 20px);
    margin: auto;
    background: transparent;
    height: auto;
    min-height: 70vh;
    max-height: calc(100vh - 177px);
    overflow-x: visible;
}

.faq {
    padding-bottom: 30px;
    overflow: scroll;
}
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