2014-03-31 19 views
1

我已經用jcarousel構建了一個幻燈片,我希望在幻燈片中幻燈片已經過渡之後讓文本生成動畫。所以幻燈片首先出現,然後文本開始動畫。如何在jcarousel中使用回調來在幻燈片中放置文本動畫?

我一直在試圖找出如何使用回調功能,以便每當幻燈片'點擊'它會觸發一些文字動畫。但是,我還沒有發現任何工程。

我想要做的是類似於這裏所描述的那樣:jQuery cycle for text animation on a slideshow

我已經研究過使用「ScrollIntoView」插件,但不認爲它做什麼,我打算。

有人知道我能做到嗎?

非常感謝

回答

0

我會targetintargetout事件偵聽器做到這一點。文檔的jCarousel事件:http://sorgalla.com/jcarousel/docs/reference/events.html

您也可以嘗試visibleinvisibleout

示例設置,如果你有每張幻燈片中的文本元素:

$('.jcarousel') 
    .on('jcarousel:targetin', 'li', function() { 
     // "this" refers to the item element 
     // "carousel" is the jCarousel instance 
     var $slide = $(this); 
     $slide.removeClass('active-slide'); 

     //sudo code, but put animations here 
     $slide.find('.text-effect-element').animate(); 
    }) 
    .on('jcarousel:targetout', 'li', function() { 
     // "this" refers to the item element 
     // "carousel" is the jCarousel instance 
     var $slide = $(this); 
     $slide.removeClass('active-slide'); 

     //sudo code, but put animations here 
     $slide.find('.text-effect-element').animate(); 
    }); 

你也可以使用CSS動畫依賴於類的父幻燈片。