2016-09-20 28 views

回答

0

您可以添加「onRendered」回調函數 我用它爲我工作

var showcase = $("#showcase") 
var card = $("#showcase .card") 
showcase.Cloud9Carousel({ 
     yOrigin: 42, 
     yRadius: 40, 
     itemClass: "card", 
     buttonLeft: $(".nav2.prev"), 
     buttonRight: $(".nav2.next"), 
     bringToFront: true, 
     onRendered: showcaseUpdated, 
     onLoaded: function() { 
      showcase.css('visibility', 'visible') 
      showcase.css('display', 'none') 
      showcase.fadeIn(1500) 
     } 
     }) 
     function showcaseUpdated(showcase) { 
     $(card).removeClass('active'); 
     var index = showcase.nearestIndex(); 
     $(showcase.items[index].element).addClass('active'); 
     } 
1

由於大衆需求,爲2.2.0版本,通過frontItemClass財產automatically tags提供您所選擇的類名最前面的項目:

var carousel = $("#carousel") 

carousel.Cloud9Carousel({ 
    // ... 
    frontItemClass: "active" 
}) 

對於JS Bin的生活demo