正しく機能しているjqueryアニメーションスクリプトがありますが、スクリプトの全体的なオーバーヘッドを減らす方法があるように感じます。開発ページへのリンクは次のとおりです。
http://dev.abinstallations.com
アニメーションには2つの部分があり、これらのアニメーションは6つの個別のdiv要素に適用されます。個別のスクリプトが各要素に適用されます。例えば:
//First
$("#first_flip").hide();
$("#first_button_show").click(function(){
$('#first_flip').animate({
opacity: 'toggle',
top: '+=524',
height: 'toggle'}, 600, function() {
// Animation complete.
});
});
$("#first_button_hide").click(function(){
$('#first_flip').animate({
opacity: 'toggle',
top: '-=524',
height: 'toggle'}, 400, function() {
// Animation complete.
});
});
//Second
$("#second_flip").hide();
$("#second_button_show").click(function(){
$('#second_flip').animate({
opacity: 'toggle',
top: '+=524',
height: 'toggle'}, 600, function() {
// Animation complete.
});
});
$("#second_button_hide").click(function(){
$('#second_flip').animate({
opacity: 'toggle',
top: '-=524',
height: 'toggle'}, 400, function() {
// Animation complete.
});
});
...残りの4つの要素についても同様です。これを達成するための凝縮された方法はありますか?