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

214
Visualizações
How do I detect swiping with RxJS?

Prerequisites

I have a slideshow, which can change the slides by calling carousel.previous(); and carousel.next();. I need to detect swiping, but only up to 1 swipe per 1s (only the last swipe gets taken due to debounceTime in RxJS).

Goal

Once I swipe right I console.log the deltaX value but only according to the prerequisites listed above.

Code prototype

function nextSlide() {
    console.log("bah1");
    carousel.next();
}

function prevSlide() {
    console.log("bah2");
    carousel.previous();
}


if (location.pathname === "/") {
    var backgroundElement = document.querySelector('.carousel');
    hammer = new Hammer(backgroundElement)
    hammer.on('panright panleft', function (event) {
        console.log(event.deltaX);
        if (event.deltaX > 250) {
            //_.debounce((event)=> { carousel.next(); }, 1000);
            _.debounce(nextSlide(), 1000);
            //event.preventDefault();
        }
        if (event.deltaX < -250) {
            //_.debounce((event)=> { carousel.previous(); }, 1000);
            _.debounce(prevSlide(), 1000);
            //event.preventDefault();
        }
    }
    ).pipe(
        map((event.deltaX) => event.deltaX.debounceTime(1000))).subscribe(x => console.log(x);)
    )
};

The errors are either missing parentheses or a missing near the arrow function, which makes no sense at all... I checked the documentation, debounceTime takes only argument.

What am I doing wrong?

StackBlitz

I apparently didn't manage to get the code to fully work but here's my try: https://stackblitz.com/edit/js-nzbkfq

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