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

169
Visualizações
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
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