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

213
Views
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
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!