S
S
Sergey Burduzha2019-05-30 17:25:00
Slick
Sergey Burduzha, 2019-05-30 17:25:00

Why doesn't event work on slide change in slick.js?

Good afternoon.
The task is to animate the content of the slide when you click on the button, as soon as the slide changes.
Show only one slide

<ul class="slides" id="js-flexslider-slick">
            <li style="background-image: url(<?php echo get_template_directory_uri(); ?>/assets/images/slider/1.jpg);">
                <div class="overlay-gradient"></div>
                <div class="container">
                    <div class="row">
                        <div class="col-md-8 col-md-offset-2 text-center js-fullheight slider-text">
                            <div class="slider-text-inner">
                                <h1>Expert Legal Solutions</h1>
                                <h2>Free html5 templates Made by <a href="http://freehtml5.co/" target="_blank">freehtml5.co</a></h2>
                                <p><a class="btn btn-primary btn-lg" href="#">Make An Appointment</a></p>
                            </div>
                        </div>
                    </div>
                </div>
            </li>

And js code
var jsSlickSLider = function(){
    $('#js-flexslider-slick').slick({
      nextArrow: '.flexslider__next',
      prevArrow: '.flexslider__prev',
      fade: true,
      speed: 2000
    });
  }

  $('#js-flexslider-slick .slick-slide').on('swipe', function(event, slick, currentSlide, nextSlide){
      console.log(slick);
    });

Why, when the slide scrolls, nothing is displayed in the console.
The documentation says
// On swipe event
$('.your-element').on('swipe', function(event, slick, direction){
  console.log(direction);
  // left
});

// On edge hit
$('.your-element').on('edge', function(event, slick, direction){
  console.log('edge was hit')
});

// On before slide change
$('.your-element').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  console.log(nextSlide);
});

What am I doing wrong again?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Usachov, 2019-05-30
@serii81

event, slick are auxiliary attributes. I suggest to hang up on beforeChange.

$('.your-element').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  слайд.eq(nextSlide).меняем_контент_в_слайде
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question