Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<script>
$(window).load(function () {

var zoom = document.getElementById("zoom");
var fade = document.getElementById("divfade1");
$("#divfade1").hide();
TweenMax.to(zoom, 1, {
left: "950px", ease: Power4.easeInOut, onComplete: function () {
$("#divfade1").fadeIn(100, function () {
TweenMax.to(zoom, 1, {
css: {
left: "0px", autoAlpha: 0
}, ease: Power4.easeInOut, onComplete: function () {
$("#divfade1").fadeOut(100)
}
});
});
}
});
});


</script>

Hello, how can you make this script run infinity times using setInterval or setTimeout? any help will be much appreciated!
Posted

1 solution

setInterval repeats again and again after interval time
setTimeout only waits once for interval time and does not repeat


C#
$(window).load(function () {
    //either use setInterval to REPEAT 
    setInterval(function () {
    //or use setTimeout if you want it to wiat once 
    //setTimeout(function () {
        var zoom = document.getElementById("zoom");
        var fade = document.getElementById("divfade1");
        $("#divfade1").hide();
        TweenMax.to(zoom, 1, {
            left: "950px", ease: Power4.easeInOut, onComplete: function () {
                $("#divfade1").fadeIn(100, function () {
                    TweenMax.to(zoom, 1, {
                        css: {
                            left: "0px", autoAlpha: 0
                        }, ease: Power4.easeInOut, onComplete: function () {
                            $("#divfade1").fadeOut(100)
                        }
                    });
                });
            }
        });
    }, 500); // change this 500 is time waited in ms so this is 0.5 seconds
});
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900