Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
how to change carousel slide on mousewheel

I'm working on a project and I need to create a vertical carousel that works on scroll (mousewheel) I just need to know how can I handle the sliding on scroll.

I have a function called nextSlide when I call then it get the next slide.

I did something like this (I checked the direction and other stuff but I'm adding the simplest code snippet here)

Note: I did Debounce on my function but it didn't work

el.addEventListener('wheel', (event) => {
  event.preventDefault();
  nextSlide();
});

The problem here is the event firing on each mouse scroll I just need to handle it on one scroll here is an example from swiper

https://codepen.io/Seamni69/pen/vYgmqVd

What I meant by one scroll is calling the function just one time when scrolling, no matter how much scrolling is.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Created this. if wheelDeltaY is positive, you are scrolling down. If it's negative you are scrolling up.

window.addEventListener('wheel', throttle(scrollDirection, 500));

function scrollDirection(e) {
  e.preventDefault();

  e.wheelDeltaY > 0 
    ? console.log("DOWN") 
    : console.log("UP")
  e.stopImmediatePropagation();
};

function throttle(func, interval) {
  let lastCall = 0;
  return function() {
    const now = Date.now();
    if (lastCall + interval < now) {
      lastCall = now;
      return func.apply(this, arguments);
    }
  };
}

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda