0

无论如何要对Cycle2 中的标题进行一些过渡效果吗?

我想对标题做一些效果,例如fadeInat each cycle-update-view

我怎样才能做到这一点?

4

2 回答 2

0

您可以通过挂钩到 jQuery 循环的 before 和 after 事件来做到这一点:

$('.cycle-container').cycle();

$('.cycle-container').on('cycle-before', function(event, options, outgoing, incoming) {
    $(this).find(options.caption).fadeOut();
});

$('.cycle-container').on('cycle-after', function(event, options, outgoing, incoming) {
    $(this).find(options.caption).fadeIn();
});

让它做一个幻灯片动画可能会稍微复杂一些,但你明白了。

于 2013-03-14T15:35:31.443 回答
0

只需连接animate.css然后将不同的过渡应用到不同的模板。如:

data-cycle-caption-template="<span class=caption1>{{caption1}}</span> <span class=caption2>{{caption2}}</span> <span class=caption3>{{caption3}}</span>"

然后上

<li 
   data-cycle-caption1="This is Slide 1 Caption 1" 
   data-cycle-caption2="This is Slide 1 Caption 2" 
   data-cycle-caption2="This is Slide 1 Caption 2" 
>

一些 CSS

.cycle-caption {
width:100%;
height:100%;
padding:20px;
position:absolute;
top:0;
left:0;
z-index:20;
opacity:1;
}


.caption1 {
font-weight:bold;
color:#FFF;
background:#000;
font-size:27px;
position:absolute;
top:20px;
left:20px;
z-index:30;
padding:5px;
-moz-animation: fadeInRight 1 ease-in 1.3s backwards; -webkit-animation: fadeInRight 1s ease-in 1s backwards; animation: fadeInRight 1s ease-in 1s backwards;
opacity: 1;
}
.caption2 {
font-weight:bold;
color:#FFF;
background:#000;
font-size:22px;
position:absolute;
top:70px;
left:20px;
z-index:40;
padding:5px;
-moz-animation: fadeInLeft 1s  ease-in 1.5s backwards; -webkit-animation: fadeInLeft 1s  ease-in 1.5s backwards; animation: fadeInLeft 1s  ease-in 1.5s backwards; 
    opacity:1;
}


.caption3 {
font-weight:bold;
color:#000;
background:#FFF;
border:1px solid rgba(0,0,0,0.5);
font-size:16px;
-moz-animation: fadeInLeft 1s ease-in 2s backwards; -webkit-animation: fadeInLeft 1sease-in 2s backwards; animation: fadeInLeft 1 sease-in 2s backwards;
position:absolute;
bottom:80px;
right:80px;
z-index:50;
padding:5px;
    opacity:1;
}

看看我的小提琴

于 2013-03-27T04:10:04.270 回答