Flickity 旋转木马作为另一个导航
2017-11-11
3441
因此,我使用这个 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-nav
的
prevNextButtons
时,自动从
.characters-main
中选择元素。
现在它的工作方式如下:
2个回答
我已将 您的示例放在此处 ,并添加了以下代码:
// 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();
});
BASEER HAIDER JAFRI
2017-11-20
请尝试使用以下代码。我使用了轻弹事件“select”。您也可以尝试解决。
var $carousel2 = $('.characters-main').flickity({
prevNextButtons: false,
wrapAround: false,
pageDots: false,
autoPlay: 10000
});
var $carousel = $('.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
}
});
$carousel.on( 'select.flickity', function(event, pointer, cellElement, cellIndex) {
if ( typeof cellIndex == 'number' ) {
$carousel2.flickity( 'select', cellIndex );
}
});
Rijo
2017-11-16