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

184
Views
La función de desplazamiento funciona rápido en mac y touchpad

Tengo un control deslizante e hice un código que va al lado y al anterior con el desplazamiento del mouse. Pero no funciona bien con mac y touchpad. ¿Cómo puedo arreglarlo? ¿Puedo poner algún retraso o algo? Intenté usar algún setTimeout pero no funcionó bien o no lo hice bien.

 $('#body').on('mousewheel', function (event) { if (typeof event.originalEvent.wheelDeltaY === 'undefined') { console.log("could not find mouse deltas") } var deltaY = event.originalEvent.wheelDeltaY; var scrolledUp = deltaY < 0; var scrolledDown = deltaY > 0; if (scrolledDown) { if (swiper_color.activeIndex > 2) { goTop(); activeIndexToTwo(); } else { swiper_color.slidePrev(); swiper_image.slidePrev(); swiper_desc.slidePrev(); swiper_title.slidePrev(); swiper_jar.slidePrev(); } } if (scrolledUp) { if (swiper_color.activeIndex < 2) { swiper_color.slideNext(); swiper_image.slideNext(); swiper_desc.slideNext(); swiper_title.slideNext(); swiper_jar.slideNext(); } else { checkscroll(); } } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Recomendaría acelerar la función. Puede escribir una función de aceleración o usar una de una biblioteca como Lodash ( Lodash throttle docs )

 function yourFn (event) { // ... all of your js here // ... } $('#body').on('mousewheel', _.throttle(yourFn, 100));

Los 100 (ms) anteriores significan que su función solo puede activarse cada 100 ms, siéntase libre de modificar el tiempo a su gusto.

about 4 years ago · Juan Pablo Isaza Report
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!