jQuery Fade - Rompiendo después de la segunda iteración hasta

I have a small issue with a fade animation I'm assembling.
It's functioning correctly twice thru the animation, and includes one wrap that works correctly.

On the second wrap, it snaps to the first photo, not fade to.
I've looked a bit at delays, but with it working correctly the first time, I'm not so sure where to go from here.

Could someone please assist?
Gracias a todos.

Enlace a JSFiddle: http://jsfiddle.net/REbuy/1/

Code Samples as Follows


var speed = 2000;
function switcher(){
$('.next').animate({opacity:1}, speed, 'linear', function()

function checker(){
        if($('.w-slides li:last').hasClass('current'))
            $('.w-slides li:first').addClass('next');
        else if($('.w-slides li:first').hasClass('next') && $('.w-slides li:last').hasClass('current'))

            $('.w-slides li:first').addClass('current');        
            $('.w-slides li.current+li').addClass('next');
            $('.w-slides li:first').removeClass('next');


    <div class="w-fader">
        <ul class="w-slides">
            <li class="current"><img src="fader-img-1.png" /></li>
            <li class="next"><img src="fader-img-2.png" /></li>
            <li><img src="fader-img-3.png" /></li>      

preguntado el 23 de abril de 13 a las 14:04

1 Respuestas

Your problem is when you wrap, you don't set the opacity of the first item back to zero.

Cambié tu checker función a esto:

function checker(){
if($('.w-slides li:last').hasClass('current'))
        $('.w-slides li:first').addClass('next').css('opacity',0);

Y parece trabajo

I guess alternatively, you could just move your call to checker to before the line in switcher where you set the opacity.

Respondido 23 Abr '13, 14:04

Thanks Matt. A simple mistake when I look at it, but firebug seems a bit quirky when updating all the values in real time. - Joe

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.