Pregunta

Tengo un temporizador jQuery va y parece echar a perder después de 2 ciclos: treethink.treethink.net/ copia de seguridad

En este momento, en diferentes temporizadores que se retraerá la barra de noticias y cambiar la cual div se muestra a continuación, hacerlo salir de nuevo. Después de un par de ciclos, que se puede ver en el enlace anterior, algunos se quedan más tiempo y luego se superponen y se hace un lío. No estoy seguro de por qué ocurre esto ...

Aquí está mi código:

/* Retracting Ticker */

    /* Initially hide all news items */

    $('#ticker1').hide();
    $('#ticker2').hide();
    $('#ticker3').hide();

    $("#ticker1").oneTime(1000,function(i) { /* Show 1 once on first pull out */

        $('#ticker1').show();

    });

    $("#ticker1").everyTime(64500,function(i) { /* Hide 3 and show 1 everytime timer gets to certain point */

        $('#ticker1').show();

    });

    $("#ticker1").oneTime(21500,function(i) { /* Hide 1 and show 2 once after first pull out */

        $('#ticker1').hide();
        $('#ticker2').show();

    });

    $("#ticker1").everyTime(86000,function(i) { /* Hide 1 and show 2 everytime timer gets to certain point */

        $('#ticker1').hide();
        $('#ticker2').show();

    });


    $("#ticker2").oneTime(43000,function(i) { /* Hide 2 and show 3 once after second pull out */

        $('#ticker2').hide();
        $('#ticker3').show();

    });

    $("#ticker2").everyTime(107500,function(i) { /* Hide 2 and show 3 everytime timer gets to certain point */

        $('#ticker2').hide();
        $('#ticker3').show();

    });

    $("#ticker3").oneTime(64000,function(i) { /* Hide 2 and show 3 once after second pull out */

        $('#ticker3').hide();

    });

    $("#ticker3").everyTime(129000,function(i) { /* Hide 2 and show 3 everytime timer gets to certain point */

        $('#ticker3').hide();

    });

    $("#ticker").oneTime(2000,function(i) { /* Do the first pull out once */

        $("#ticker").animate({right: "0"}, {duration: 800 });
    });

    $("#ticker").oneTime(20000,function(i) { /* Do the first retract once */

        $("#ticker").animate({right: "-450"}, {duration: 800});

    });

    $("#ticker").everyTime(21500,function(i) { /* Everytime timer gets to certain point */

        $("#ticker").animate({right: "0"}, {duration: 800}); /* Pull out right away */

        $("#ticker").oneTime(20000,function(i) { /* Retract once */

            $("#ticker").animate({right: "-450"}, {duration: 800});

        });

    });

Gracias,

Wade

¿Fue útil?

Solución

Vamos a ignorar todas las oneTimes ya que no van a ensuciar para arriba.

$("#ticker1").everyTime(64500,function(i) {
    $('#ticker1').show();
});

$("#ticker1").everyTime(86000,function(i) { 
    $('#ticker1').hide();
    $('#ticker2').show();
});

$("#ticker2").everyTime(107500,function(i) {
    $('#ticker2').hide();
    $('#ticker3').show();
});

$("#ticker3").everyTime(129000,function(i) { 
    $('#ticker3').hide();
});

$("#ticker").everyTime(21500,function(i) { 
    $("#ticker").animate({right: "0"}, {duration: 800});
    $("#ticker").oneTime(20000,function(i) { 
        $("#ticker").animate({right: "-450"}, {duration: 800});
    });
});

Usted tiene 4 objetos:. Teletipo, el contenedor, y 3 mensajes

El comportamiento del contenedor es esto (aproximadamente, y sin contar la primera extracción): cada 21,5 segundos, ocultan durante 1,5 segundos y luego se deslizan de vuelta. Bien, este no es el origen del problema, los 3 temporizadores de mensajes son el problema.

Este es el comportamiento de mensajes en los intervalos:

ticker    show (s)   hide (s)
1         64.5       86
2         86         107.5
3         107.5      129

Editar que tenía mis números equivocados por primera ticker intervalo de tiempo, pero sigo pensando que la idea es la misma. Con el tiempo, los tiempos se superponen.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top