Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!