0

jQuery でのアニメーションの問題を解決できることを願っています。次のコードを使用して、開始および停止できるアニメーション ループを作成しています。また、アニメーション化されている要素がパルス状であるか、矢印のように動いているかを選択できます。

//set the flashing pointer on or off
function flashPointer(state, time, el, style){
    switch(state){
        case "on":
            loopPointer(time, style, el);
        break;
        case "off":
            $(el).stop(true, false).fadeOut(100, function(){ 
                $(el).clearQueue();
            });
        break;
    }   

}

//make a pointer graphic fade in and out
function loopPointer(time, style, el){
    switch(style){
        case "fade":
        $(el).fadeIn(time, function(){
            $(this).fadeOut(time, function(){
                loopPointer(1000, "fade", el);
            }); 
        });
        break;

        case "move":
        $(el).fadeIn(time).animate({top:15}, time, function(){
            $(this).animate({top:0}, function(){
                loopPointer(1000, "move", el);
            }); 
        });
    }
}

アニメーションを何度も開始および停止すると、アニメーションが徐々に遅くなる理由は何ですか?

もちろん、その他のコメントや改善点も大歓迎です。

皆さんありがとう ;)

ジェイミー

アップデート

これらの関数を次のように呼び出しています。

flashPointer("on", 1000, "#pointer", "move");
flashPointer("off", 1000, "#pointer", "move");
flashPointer("on", 1000, "#pointer", "fade");
flashPointer("off", 1000, "#pointer", "fade");

たとえば、ブラウザがユーザーの地理的位置情報へのアクセスを要求したときに、上記の関数を 1 回呼び出してフェーダーをオンにし、必要な情報/許可が与えられたらもう一度呼び出してオフにします。

私がやろうとしていることを説明するのに役立つことを願っていますか?

ご協力いただきありがとうございます!

ジェイミー

4

0 に答える 0