確かにjQueryは初めてですが、JavaScriptを少し知っています。いくつかのアニメーションでdivをアニメーション化しようとしています。
最初に div をページの中央に移動してから、中央に達したら反転させてから展開します。
私が抱えている問題は、.animate()
メソッドを使用して divのtop
およびプロパティを変更し、それを中央に配置することです。left
問題は、 moveToCenter 関数の .animate メソッドが実際には動きを中央にアニメーション化しないことです。アニメーション部分をスキップするだけで (プロパティは変更されますが、変更はアニメーション化されません)、フリップと残りの部分に進みます。
なぜこれが起こっているのか/どこが間違っているのか教えてもらえますか?
そして、それを(もしあれば)どのように修正できますか?
HTML
<div id="flip" style="background-color:#ff0000;
width:200px;
height:200px;
position:absolute">
<h4> printf("Hello World"); </h4>
</div>
JS
function moveToCenter()
{
$('#flip').animate({'top':'300','left':'300'});
}
$(document).ready(function() {
$('#flip').click( function() {
moveToCenter(); //function that is supposed to moves the div to the center
$(this).flip({
content: 'Scanf()',
color: '#00FF00',
direction: 'lr',
onEnd: function(){ $('#flip').animate({
'height' : '400', 'width': '300'
}
,'500','swing');
lol(); //Another function that does some other animations
}
});
});
});