クリックやオンマウスで画像を回転させたりするとき
function spin() {
//z-indexを0から1に変更する
$('#sample img').animate({
'z-index': 1//多分なんでも良い。一番影響ないものはこれ。
},
{
duration: 1000, //アニメーションの時間
//ステップ中の処理
//引数num:処理途中の変化している値
step: function (num) {
//処理途中の値を使ってちょっとずつ回転させる
$(this).css({
transform: 'rotate(' + (num * 360) + 'deg)'
});
},
//完了時の処理
//次回のことを考えz-indexを1から0に戻す
complete: function () {
$('#sample img').css('z-index', 0);
}
});
}