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

136
Views
Execute one or other function when the user swipes right or left on a picture - RxJS

Goal

My goal is to call a function for a slideshow which changes the slide to the next or the previous one. It's that simple

Code

if (location.pathname === "/") {
    var backgroundElement = document.querySelector('.carousel');
    hammer = new Hammer(backgroundElement)
    hammer.on('panright panleft', function (event) {
        var stream = rxjs.fromEvent(backgroundElement, 'deltaX');
        stream.pipe(
            rxjs.map((i) => console.log(i)),
            rxjs.debounceTime(1000)
        )
        .subscribe(j => {
            console.log(j);
            if (j.deltaX > 250) { carousel.next(); }
            else if (j.deltaX < -250) { carousel.previous(); }
        });
    })
}

Errors

None appear apparently. Adding error => console.log(error); to the subscription appears to do nothing as well. Nothing is console logged either... I at least want to get a console log...

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!