ストップの使い方を読んで、他の答えをここで見てみました。このスニペットをいじくり回している時間が長すぎます。このアニメーションを常に平行にすることはできないようです。
ある時点で停止するか、ボトムラインでアニメーションをキューに入れ続けます(以下のコードを参照)。いずれにせよ、これを正しく機能させるためにどこにストップを置くべきかわかりません。
$(".property-wrapper").hover(function(e){
var lines = new Array();
lines.push($(this).find(".line-top"));
lines.push($(this).find(".line-left"));
lines.push($(this).find(".line-right"));
lines.push($(this).find(".line-bottom-right"));
lines.push($(this).find(".line-bottom-left"));
if(e.type == "mouseenter")
{
// Animate, starting from top, and going parallell towards the bottom. Then the bottom ones meet eachother.
// The motion forms a square
/*
Index 0 starts (from main.css) on left:50%; and animates to 0 while also animating width to 100%, giving
the illusion of it "shooting" out in both directions
Here is a representation of the indices and their direction of animation
<---------0--------->
1 2
| |
| |
| |
|4--------><-------3|
*/
$(lines[0]).animate({width:"100%", left:0}, 'fast', function(){
$(lines[1]).animate({height:"100%"}, 'slow' , function(){
$(lines[4]).animate({width:"50%"}, 'slow');
});
$(lines[2]).animate({height:"100%"}, 'slow', function(){
$(lines[3]).animate({width:"50%"}, 'slow');
});
});
}
else
{
// Reverse the animation on mouseenter
$(lines[3]).animate({width:0}, 'fast', function() {
$(lines[2]).animate({height:0}, 'slow', function(){
$(lines[0]).animate({width:0, left:"50%"}, 'fast');
});
});
$(lines[4]).animate({width:0}, 'fast', function() {
$(lines[1]).animate({height:0}, 'slow');
});
}
});
誰もが助けてくれることを願っています!ありがとう
編集:基本的には次のように設定されます。
<div>
<div class="line-top"></div>
<div class="line-left"></div>
<div class="line-right"></div>
<div class="line-bottom-right"></div>
<div class="line-bottom-left"></div>
</div>
そしてこれがCSSです。線divの親は相対的に配置され、線は親に対して相対的な位置を制御するために絶対的です。
.line-top, .line-left, .line-right, .line-bottom-right, .line-bottom-left
{ background:red; position:absolute; }
.line-top { height:1px; width:0; left:50%; top:0; }
.line-left { width:1px; height:0; left:0; top:0; }
.line-right { width:1px; height:0; right:0; top:0; }
.line-bottom-right { height:1px; width:0; right:0; bottom:0; }
.line-bottom-left { height:1px; width:0; left:0; bottom:0; }