I am using viewport checker and I want the animation to only run once, so far I have the following:-
jQuery('#style-wrapper').viewportChecker({
callbackFunction: function(elem) {
var flag = true;
interval = setInterval(function(){
jQuery('.page-template-template-homepage .work-description').html('Different');
jQuery('.page-template-template-homepage .work-description').css( "font-weight", "700" );
jQuery('.page-template-template-homepage #style-wrapper').css( "background", "#7ec4bf");
jQuery('.page-template-template-homepage #style-wrapper').css( "color", "#14143a");
},1000);
interval = setInterval(function(){
jQuery('.page-template-template-homepage .work-description').html('Distinct');
jQuery('.page-template-template-homepage .work-description').css( "font-weight", "900" );
jQuery('.page-template-template-homepage #style-wrapper').css( "background", "#14143a");
jQuery('.page-template-template-homepage #style-wrapper').css( "color", "#FFFFFF");
},2000);
interval = setInterval(function(){
jQuery('.page-template-template-homepage .work-description').html('People');
jQuery('.page-template-template-homepage #style-wrapper').css( "background", "#b0a893");
},3000);
interval = setInterval(function(){
jQuery('.page-template-template-homepage .work-description').html('Want');
jQuery('.page-template-template-homepage .work-description').css( "font-weight", "900" );
jQuery('.page-template-template-homepage .work-description').css( "font-size", "54px" );
jQuery('.page-template-template-homepage #style-wrapper').css( "background", "#39779f");
jQuery('.page-template-template-homepage #style-wrapper').css( "color", "#14143a");
},4000);
if (flag) {
interval = setInterval(function(){
flag = false;
},5000);
}
}
});
but for some reason it keeps looping over and over again (and for some unknown reason, when it loops the second time it starts going in a different sequence).
Any ideas?