私はjQueryで非同期アプリケーションを構築しようとしています。私は最近、setIntervalが関数への定数呼び出しをどのように行い、他の関数のロジックがその準備ができていない場合でもアクティビティを保護するという概念のいくつかを学びました。私が示しているコードは、私がやりたいことの草案です。作業コピーではありません。私の問題は、アニメーションの一部を無期限に一時停止し、残りの部分を(準備ができたら)再開するロジックを作成するように見えないことです。アニメーションコールバック関数でどのようにロジックを作成するのですか?それを理解しようとしているもののおかげjQueryアニメーションコールバック関数でどのようにロジックを作成しますか?
var runAnimation;
var timePassed;
var someThing;
$(document).ready(function(){
asyncFunction();
});
function asyncFunction() {
if (someCondition == true) {
animationFunction(){
}
}
runAnimation = setInterval(animationConditions, 100)
}
function animationConditions(){
if (timePassed = 30) {
if( someThing == true) {
animationFunction() {
}
}
timePassed += 1;
}
function animationFunction() {
$('#show div')
.animate({left: 500},1500)
.delay(3000)
.queue(function(){
someThing = false;
//but in this section I would like something like a mouseover or
//other things to be able to pause the animation. I was experimenting
//with queue and dequeue but any time I use dequeue in this section
//it turns of the queue, even if the statement fails. For exmaple if it
//is in an else and the if is true. I would like to be able to add more
//pause on an event like a mouseover. When mouse leaves resume the animation.
//if(something == true){
// pause aniamtion indefinitely;
//}
}).dequeue().animate({left: 1100},1500);
}
は私があれば()内のコードが実行されない理由を私は理解していないこの
function animatePause(query, duration, distance){
checkAp = setInterval(function(){
if(marqueeVars.autoPlay == false) {
console.log("that's one");
query.delay(70000000000000000).animate({left: distance},function(){
clearInterval(checkAp);
console.log("long wait!");
});
} else {
console.log("that's two");
//console.log(query.html());
//clearInterval(checkAp);
query.delay(duration).animate({left: distance},function(){
clearInterval(checkAp);
console.log("regular wait!");
animateOut(query,1100);
});
}
}, 100);
}
を思い付きましたか?インターバルをクリアすることは決してありません。アニメーションを実行することはありませんか?それは単に無視されるようです。私はこのコンセプトを、私がプラグインを見るつもりであると思っていると理解しなければならないと思う。ありがとう
これは2度目のことですが、私はGreenSock pulginをチェックします。ありがとう – bistel
方法を見つけようとしているうちに私はこれを思いついた: – bistel
あなたのコメントへのリンクを追加していなかったと思います...とにかく、どうしたらいいか教えてください。非常に理解しやすい –