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

173
Views
Difference in scroll animation up and down even though the code is the same + need to stop new inputs while animating

I have this scroll animation that moves a div up and down simulating a scroll, why is there a difference in behaviour from the up and down movement?

let position = '';
let scrolling = false;
let animationDuration = 800;

let position = '';
let scrolling = false;
let animationDuration = 800;

$(window).bind('mousewheel', function(event) {
  if (event.originalEvent.wheelDelta > 0) {
    // scroll up
    if (scrolling || position === 'top')
      return;
    scrolling = true;
    position = 'top';
    $('#bottom').stop().animate({
        top: "100vh"
      }, animationDuration, 'linear',
      function() {
        scrolling = false;
      },
    );
  } else {
    if (scrolling || position === 'bottom')
      return;
    scrolling = true;
    position = 'bottom';
    $('#bottom').stop().animate({
        top: "0"
      }, animationDuration, 'linear',
      function() {
        scrolling = false;
      },
    )
  }
})

https://jsfiddle.net/o4vg6f8y/1/

when moving the #bottom up it seems like it starts from where you end your scroll input, this behaviour is not wanted.

I want the same movement as when you roll the wheel from bottom to top

Also, I need to stop overlapping inputs while the animation is active, this problem causes glitches.

Thank you for the help.

EDIT: WTF I think I've solved it with a body {overflow:hidden;} Maybe the possibility to scroll was messing up with the general animation.

By the way I would like to listen if there's something more to know about it. Thank you.

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!