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

129
Views
I want the page to scroll down, top automatically when my cursor is near the top or bottom of the page

For example, I want the page to scroll down automatically when I approach until there is 10px of space at the bottom. I want the same scenario to happen when I move the cursor up.

#list-container{
    background-color: rebeccapurple;
    cursor: default;
    overflow-y: auto;
    height: 200px;
    padding: 10px;
}
#list{
    padding: 10px;
    margin: 10px;
}
        <div id="list-container">
            <ol id="list" >
                <li>zero</li>
                <li>one</li>
                <li>two</li>
                <li>three</li>
                <li>four</li>
                <li>five</li>
                <li>six</li>
                <li>seven</li>
                <li>eight</li>
                <li>nine</li>
                <li>ten</li>
                <li>eleven</li>
                <li>twelve</li>
                <li>thirteen</li>
                <li>fourteen</li>
                <li>fifteen</li>
            </ol>
        </div>

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Check the following code, it might help:

let false = false;

window.addEventListener('scroll', () => {
    if(window.innerHeight + window.scrollY >= document.body.offsetHeight - 1000 && ready)
    {
        ready = false;
        << your code here >>
    }
});
about 4 years ago · Juan Pablo Isaza Report

0

I was able to solve my problem like this guys, I hope I can help someone else

 $("body").bind("mouseover", function (e) {
        e = e || window.event; var cursor = { y: 0 }; cursor.y = e.pageY; //Cursor YPos
        var papaWindow = parent.window;
        var $pxFromTop = $(papaWindow).scrollTop();
        var $userScreenHeight = $(papaWindow).height();

        if (cursor.y > (($userScreenHeight + $pxFromTop) / 1.15)) {

          if ($pxFromTop < ($userScreenHeight * 3.2)) {

            papaWindow.scrollBy(0, ($userScreenHeight / 30));
          }
        }
        else if (cursor.y < (($userScreenHeight + $pxFromTop) * 0.75)) {

          papaWindow.scrollBy(0, -($userScreenHeight / 30));

        }
      });

and where your code ends after binding to "body"

$("body").unbind("mouseover");

if we don't want it to follow our mouse we have to unbind it

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