I'm currently setting up a slider for my website and I ran into some problems.
I use bxslider and I wanted to add animations for the text in each slide by adding animate.css. Animate.css is pretty simple: just add "animated" and the animation name as classes to the animated element.
Basically, I want text to appear on a slide with an animation after the slider finished the transition to the slide. I also want the text to fade out before the transition to the next slide with the next text.
Since the slider has callback-functions I thought it would be straightforward to just add the necessary CSS-classes through.
JQUERY
$(document).ready(function(){
$(".bxslider").bxSlider({
auto: true,
startSlide: 0,
slideWidth: 640,
onSlideAfter: function(){
$(".title").addClass("animated bounceInRight");
$(".text").addClass("animated bounceInRight");
},
onSlideBefore: function(){
$(".title").removeClass("animated bounceInRight");
$(".text").removeClass("animated bounceInRight");
}
});
});
HTML
<ul class="bxslider">
<li><img src="" />
<h1 class="title animated bounceInRight">TITLE 1</h1><p class="text animated bounceInRight">
text text text text text text
text text text text text text
</p></li>
<li><img src="" /><h1 class="title">TITLE 2</h1><p class="text">
text text text text text text
text text text text text text
</p></li>
<li><img src="" /><h1 class="title">TITLE 3</h1><p class="text">
text text text text text text
text text text text text text
</p></li>
<li><img src="" /><h1 class="title">TITLE 4</h1><p class="text">
text text text text text text
text text text text text text
</p></li>
</ul>
CSS 1 (what I added to the slider's default CSS)
.bxslider {
padding: 0;
margin: 0;
list-style: none;
}
.title {
position: absolute;
top:100px;
left: 100px;
color: #FFF;
font-family: Helvetica;
}
.text {
display: block;
position: absolute;
top:200px;
left: 200px;
color: #000;
font-family: Helvetica;
width: 300px;
background: #FFF;
-webkit-animation-delay: 1s; /* to delay text "entrance" */
}
CSS 2 (animation "trigger"... the different animations are just CSS3 animations with keyframes and so on)
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
I put an example slider online: bxslider test.
There are several problems so far. I will always refer to "text", but I mean both the <h1> and the <p> tags.
First: The first slide is animated correctly, the text appears with animations. On the second slide, the text is already visible and then the animation starts. I want the text to appear "through" the animation.
Second: I tried adding the fadeOut-effect (again by adding and removing the corresponding CSS-classes). It won't work, the fadeOut will happen after the transition to the next slide. I guess I make some fundamental mistake with adding and removing the classes, but I can't figure it out.
Third: Could I use different entrance-effects on each slide, maybe even randomly?
Fourth: There seems to be a bug in Safari. On my computer (Safari & Chrome) the slideshow starts with the first slide. On the webserver in Safari, the last slide is visible first and then it srolls through the first slide directly to the second slide... very strange. In Chrome the slideshow looks normal. There are no problems with the code according to Safari's log
It would be really nice if someone could help me out with this, at least for the first two problem.
Thank you!
display: nonefor the container of the texts to solve your first problem, but I'm not entirely sure what they are and what CSS is currently applied. - cr0ssh1andpinside a DIV, set this DIV's CSS todisplay: noneand run. I think the animation sets its visibility back - cr0ss