Flickity轮播作为另一个导航

LuT*_*uTz 5 javascript jquery slider flickity

所以,我正在使用这个https://codepen.io/desandro/pen/wByaqj

prevNextButtons: true,像这样激活了:

$('.characters-main').flickity({
      prevNextButtons: false,
      wrapAround: false,
      pageDots: false,
      autoPlay: 10000
    });
    $('.characters-nav').flickity({
      asNavFor: '.characters-main',
      cellAlign: 'right',
      prevNextButtons: true,
      contain: true,
      pageDots: false,
      arrowShape: {
        x0: 10,
        x1: 70, y1: 50,
        x2: 70, y2: 50,
        x3: 35
      }
    });
Run Code Online (Sandbox Code Playgroud)

我想要的是,当我单击prevNextButtonsfor .characters-nav时自动从中选择元素.characters-main

现在是这样的:

在此处输入图片说明

BAS*_*FRI 5

我已经在这里接受了您的示例,并添加了以下代码:

 // Main div
    var flkty = new Flickity('.carousel-main');

   // Next and previous events of the navigation div
    $(".carousel-nav .next").on("click", function() {
          // Changing items of the main div
           flkty.next();
    });



 $(".carousel-nav .previous").on("click", function() {
          // Changing items of the main div
          flkty.previous();
    });
Run Code Online (Sandbox Code Playgroud)

以您的情况为例:

         // Your main div is characters-main
        var flkty = new Flickity('.characters-main');

       // Next and previous events of the characters-nav
        $(".characters-nav .next").on("click", function() {
              // Changing items of the main div
               flkty.next();
        });



     $(".characters-nav .previous").on("click", function() {
              // Changing items of the main div
              flkty.previous();
        });
Run Code Online (Sandbox Code Playgroud)