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

159
Visualizações
javascript mousewheel event

It went wrong when the currentSlide over the total slide. I use if conditions to restrict the range of currentSlide number, but the if condition can't return the value to the currentSlide. Here is the demo.

  var pageLength = $(".image").length,
    scrolling = false,
    currentPage = 0,
    pages = $(".image");

  function pageMove() {
    scrolling = true;
    setTimeout(function() {
      scrolling = false;
    }, 500);
  }

  function navigateUp() {
    if (currentPage > 1) {
      currentPage--;
      pageMove();
      if (currentPage < 0) {
        currentPage = pageLength;
      }
    }
    pages[currentPage].style.transform =
      "translateY(" + currentPage * 100 + "%)";
  }

  function navigateDown() {
    if (currentPage < pageLength) {
      currentPage++;
      pageMove();
      if (currentPage > pageLength - 1) {
        currentPage = 0;
      }
    }
    pages[currentPage].style.transform =
      "translateY(-" + currentPage * 100 + "%)";
  }

  //MOUSEWHEEL
  $(document).on("mousewheel DOMMouseScroll", function(e) {
    if (!scrolling) {
      if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
        navigateUp();
      } else {
        navigateDown();
      }
      console.log(currentPage);
    }
  });
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