함수 안에 애니메이션이있다. 함수를 떠나기 전에 애니메이션을 먼저 끝내야한다고 어떻게 코딩 할 수 있습니까? 코드를 기반으로Jquery 함수가 끝나기 전에 애니메이션이 끝날 때까지 기다린다.
이ShowBanner.prototype.basicRotate = function (pos, callback) {
var self = this;
self.animation = true;
this.bigbannerScroll.animate({
left: pos
}, this.settings.rotateSpeed, function() {
self.animation = false;
if (callback) callback();
console.log('animation done');
return false;
});
console.log('function done');
}
의 console.log('function done')
가 console.log('animation done')
전에 먼저 호출됩니다
animate가 비동기 함수이기 때문에 콜백 메커니즘을 사용해야합니다. –