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

207
Visualizações
Slick slider navigation with next, previous, paging info and toggle for autoplay, is there a better way to integrate the toggle?

I am trying to make a slick slider with next and previous arrows, paging info and a toggle for autoplay. I have everything working except if you have selected autoplay and then click the previous arrow, the autoplay toggle now longer works.

Here is my js so far:

var $status = $('.pagingInfo');
var $slickElement = $('.slideshow');

$slickElement.on('init reInit afterChange', function (event, slick, currentSlide, nextSlide) {
 
  if(!slick.$dots){
    return;
  }

  var i = (currentSlide ? currentSlide : 0) + 1;
  $status.text(i + ' of ' + (slick.$dots[0].children.length));
});

$slickElement.slick({
    infinite: false,
    slidesToShow: 1,
  autoplay: false,
    autoplaySpeed: 1000,
    speed: 300,
  dots: true,
            pauseOnFocus: false, 

    prevArrow: $('.prev'),
      nextArrow: $('.next'),
});

$('#toggle1').click( function() {
  if ($(this).html() == 'pause'){
    $slickElement.slick('slickPause')
     $(this).html('play') 
  } else {
    $slickElement.slick('slickPlay')  
    $(this).html('pause') 
  }  
});

Here is the slider so far: https://codepen.io/wjgoodman/pen/GRMEvpQ

Does anyone know how to better integrate the toggle so the toggle works after clicking a next or previous arrow?

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