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

117
Visualizações
How do I resolve slide (carousel) overlapping?

I'm posting for the first time. The question format may be a mess, but I look forward to your kind cooperation.

[My ISSUE]
Currently, the website is being produced using Next.js. A total of six slide functions were created, and there is one problem. A separate laptop and mobile environment were created, but when the laptop reduces the browser to mobile or vice versa, a problem occurs on the slide.

enter image description here

I don't know if this is called an overlapping phenomenon, the between each slide image appears like each picture. Only One picture should be in the center under those slide dots, but two are displayed.

I've thought of a solution, but I don't have a clue.

//My Slide Component

//the id value was given from zero. (total of six pictures)
const totalSlide = 5; 

const slideRef = useRef();
const [currentSlide, setCurrentSlide] = useState(0);

const prevEvent = () => {
 if (currentSlide === 0) setCurrentSlide(totalSlides);
   else setCurrentSlide(currentSlide - 1);
 };

const nextEvent = () => {
 if (currentSlide >= totalSlides) setCurrentSlide(0);
   else setCurrentSlide(currentSlide + 1);
 };

useEffect(() => {
  slideRef.current.style.transition = 'all 0.4s ease-out';

  //The mobile environment was set to 1024px or less.
  if (window.innerWidth >= 1024) {
      slideRef.current.style.transform = `translateX(-${currentSlide * 650}px)`;
    } else {
      slideRef.current.style.transform = `translateX(-${currentSlide * 360}px)`;
    }
}, [currentSlide]);

[My wish result]
Even if there is a change in browser size, we want only one picture to appear without overlapping slides. Even if the margin between images is reached as shown in the picture by overlapping, we want to fix it by returning to its place or initializing to zero according to the id value displayed by the slide dots.

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