ここでは、ループ内で継続する一連のアニメーションがあり、最初の繰り返しでのみ関数を呼び出そうとしています。最初の繰り返しが終了すると、関数を呼び出さないでくださいもうどうやってやるの?ここでループ内で最初に関数を呼び出す方法
は私のコードは
var r5anim1 = function(){
$(".r5").velocity({
opacity: 1,
scale: [1,0],
}, {
duration:300,
complete: function() {
r5anim2();
}
});
}
var r5anim2 = function(){
$(".r5").velocity({
opacity: 0,
},{
duration:200,
complete: function() {
r6anim1();
wishes() // here i have called the function which should execute only on first loop.
}
});
}
var r6anim1 = function(){
$(".r6").velocity({
opacity: 1,
scale: [1,0],
}, {
duration:300,
complete: function() {
r6anim2();
}
});
}
var r6anim2 = function(){
$(".r6").velocity({
opacity: 0,
},{
duration:200,
complete: function() {
r5anim1(); //on end this will start the loop again
}
});
}
/*****************this function should be called only for the first time******************/
var wishes = function(){
boolvalue = 0;
$(".wishes").velocity({
opacity: 1,
scale: [1,0.4],
}, {
duration:600,
});
}
r5anim1();
ループ外に1つの一時変数を宣言し、デフォルト値をtrueに設定し、true呼び出し関数が呼び出された関数がfalse – Bharat