0

Is there anyway to make some transition effects to the caption in Cycle2?

I want to make some effects to the caption such as fadeIn at each cycle-update-view.

How can I do that?

NoBugs
  • 9,310
  • 13
  • 80
  • 146

2 Answers2

0

you can do this by hooking into jQuery cycle's before and after events:

$('.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();
});

It might be slightly more complicated to get it do a slide animation, but you get the idea.

jordancooperman
  • 1,931
  • 2
  • 21
  • 33
0

Just hookup with animate.css then apply different transitions to different templates. Such as:

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

Then on

<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" 
>

Some 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;
}

Check out my Fiddle

Charles Butler
  • 573
  • 3
  • 15
  • This is pretty interesting, looks like a great idea. But I can't figure out how to apply the animation to each slide. For me it only animates on page load, but not as each slide changes. Any tips?? – Trevor May 30 '14 at 17:02