Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control two slick sliders with only one navigator

I'm using Slider Syncing from Slick.js and need to control with only one navigator the other two.

<div class="main">
  <div>content</div>
  <div>content</div>
</div>
<div class="navigator">
  <div>nav1</div>
  <div>nav2</div>
</div>
<div class="secondary">
  <div>content related with main1</div>
  <div>content related with main2</div>
</div>

And this is my js code for that

var slickMainFrame = {
    slidesToShow: 1,
    slidesToScroll: 1,       
    arrows: true,
    fade: true,
    asNavFor: '.navigator',
};

var slickNav = {
    dots: false,
    slidesToShow: 2,
    slidesToScroll: 1,       
    arrows: true,
    fade: true,
    asNavFor: '.main',
    speed: 500,
};

$('.main').slick(slickMainFrame);
$('.secondary').slick(slickMainFrame);
$('.navigator').slick(slickNav);

This is not working at all.. I've tried using the asNavFor attribute of slickNav as an array or colon separated but it's not working neither. asNavFor: '.main, .secondary'

like image 883
Julioarhernandez Avatar asked Dec 25 '22 10:12

Julioarhernandez


1 Answers

Try this:

HTML

<div class="main asnavForClass">
  <div>content</div>
  <div>content</div>
</div>
<div class="navigator">
  <div>nav1</div>
  <div>nav2</div>
</div>
<div class="secondary asnavForClass">
  <div>content related with main1</div>
  <div>content related with main2</div>
</div>

Javascript

 var slickMainFrame = {
   slidesToShow: 1,
   slidesToScroll: 1,       
   arrows: true,
   fade: true,
 };
 var slickNav = {
   dots: false,
   slidesToShow: 2,
   slidesToScroll: 1,       
   arrows: true,
   fade: true,
   asNavFor: '.asnavForClass',
   speed: 500,

};



$('.main').slick(slickMainFrame);
$('.secondary').slick(slickMainFrame);
$('.navigator').slick(slickNav);

Check the JSFiddle for a working example

like image 139
Baro Avatar answered Dec 27 '22 02:12

Baro