0

私は、divが特定の位置の右側に移動し、その後、下の手段に移動するデモコードを使用しています

DIV started moving------------------>     
                                    . Div turn to bottom        
                                    .
                                    .
                                    .
                                    .
                                    .
                                    V
                       Div's place after move and turn

このタイプのアニメーションを作成するには、どのコードを読んで使用する必要がありますか。私は2つのコード形式を知るようになりました。デモステーション用に 2 つのコードを貼り付けています。

この問題を解決する方法:

    1. $( 'span' ).animate({ 
        // Properties of the elements to animate 
        opacity: 0.25, 
        left: '+=50' 
    }, 
    { 
        // step is a callback for each step of the animation 
        step: function( now, fx ) { 
            // do stuff... 
        } 
    }); 


  2. $.when($('#foo').animate({
            top: 100,
            left: 100
        }, 3000)).pipe(function() {
            return this.animate({
                top: 0,
                left: 0
            }, 3000);
        }).then(function() {
            console.log('done');
        });
4

1 に答える 1

0

ここで延期する必要はありません。何かが完了した後に実行されるコールバックがあるため、when/then/pipe の遅延メソッドをキャッチする必要はありません。

$('span').animate({
    top: 100,
    left: 100
}, 3000, function(){
    $('span').animate({
        top: 0,
        left: 0
    }, 3000, function(){ 
        console.log('done')
    });
});

これがjsFiddleです

于 2012-10-24T17:45:27.143 に答える