Я использую видовую шашку, и я хочу анимацию работать только один раз, до сих пор я следующее: -Viewport Checker - JQuery запустить цикл один раз
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);
}
}
});
, но по какой-то причине он продолжает цикл снова и снова снова (и по какой-то неизвестной причине, когда он петли второй раз, он начинает двигаться в другой последовательности).
Любые идеи?
Может быть что-то вроде $ ('# стиль-обертка') один() viewportChecker ({..})..; – Mark