function animateProp(opts) {
var start = opts.start, end = opts.end, prop = opts.prop;
opts.step = function(progress) {
opts.elem.style[prop] = (end - start) * progress + start+'px'
}
return animate(opts);
}
var logo = document.getElementById('logo');
logo.onmouseover = function () {
if (logo.busy) return;
logo.busy = true;
animateProp({start:0, end: -20, prop:'marginTop', duration:500, elem:logo},function() {
logo.busy = false;
})
}
logo.onmouseout = function () {
if (logo.busy) return;
logo.busy = true;
animateProp({start:-20, end: 0, prop:'marginTop', duration:500, elem:logo},function() {
logo.busy = false;
})
}
работает только при onmouseover