gpt4 book ai didi

javascript - Flickity 轮播作为另一个导航

转载 作者:数据小太阳 更新时间:2023-10-29 06:09:43 24 4
gpt4 key购买 nike

所以,我正在使用这个 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
}
});

我想要的是,当我点击 .characters-navprevNextButtons 时,自动从 .characters-main 中选择元素。

现在是这样工作的:

enter image description here

最佳答案

我拍了Your Example over here并且我添加了以下代码:

 // 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();
});

在你的案例中应该是这样的:

         // 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();
});

关于javascript - Flickity 轮播作为另一个导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47241086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com