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
¿Por qué necesito un contador para las imágenes en un carrusel de diapositivas y por qué es tan fundamental que las imágenes se muevan de la manera correcta?

Estoy siguiendo un tutorial sobre cómo hacer un control deslizante de carrusel de imágenes. Traté de desglosar el problema con lápiz y papel, pero nunca supe que necesitaría un contador para las imágenes. Siento que solo estoy copiando el código y realmente no lo entiendo. Si alguien pudiera explicarme esto sería genial.

 const slideContainer = document.querySelector(".slide") const carouselImages = document.querySelectorAll(".carousel-container img") const lastCloneImage = document.querySelector("#last-clone-image") const firstCloneImage = document.querySelector("#first-clone-image") const prevArrowButton = document.querySelector("#prev") const nextArrowButton = document.querySelector("#next") let counter = 1; const size = carouselImages[0].clientWidth nextArrowButton.addEventListener("click", imageNextMove) prevArrowButton.addEventListener("click", imagePrevMove) // this selects the slide with the images in it and moves the container itself with all the images in it slideContainer.style.transform = 'translateX(' + (-size * counter) + 'px)'; function imageNextMove() { slideContainer.style.transition = 'transform 0.4s ease-in-out' counter++; slideContainer.style.transform = 'translateX(' + (-size * counter) + 'px)'; } function imagePrevMove() { slideContainer.style.transition = 'transform 0.4s ease-in-out' counter--; slideContainer.style.transform = 'translateX(' + (-size * counter) + 'px)'; }
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!