여기 루프에서 계속되는 애니메이션 집합이 있는데 첫 번째 반복에서만 함수를 호출하려고하는데 첫 번째 반복이 끝나면 함수를 호출하면 안됩니다. 더 이상. 내가 어떻게 할 수 있니? 여기 루프에서 처음으로 함수를 호출하는 방법
전역 변수를var isTriggered = false;
테스트를 만들기 내 코드
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();
루프 외부에서 임시 변수 하나를 선언하고 기본값을 true로 설정하고 true 호출 함수가 호출 된 함수가 false가되면 루프에서 확인합니다 – Bharat