Как мне написать это более эффективно?
HTML
<div class="navigation-left">left</div>
<div class="navigation-right">right</div>
Js
$(document).ready(function(){
var offs = 0,
speed = 700;
$('.navigation-left').animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 100
}, speed);
$('.navigation-right').animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 100
}, speed);
});
Смотрите jsfiddle здесь: http://jsfiddle.net/klawisz/nESMD/