Deff,
var time = 1000;
var intervalID = window.setInterval(correct, time);
function correct()
{
var widthSlide;
var book1 = document.getElementById('book1').offsetLeft;
var book2 = document.getElementById('book2').offsetLeft;
var book3 = document.getElementById('book3').offsetLeft;
var book4 = document.getElementById('book4').offsetLeft;
if(условие)
{
действие
}
else
{
clearInterval(intervalID);
setTimeout(width, 100);
}
}
(function(time)
{
var time1;
window.onresize = function(e)
{
if (time1)
clearTimeout(time1);
time1 = setTimeout(function(time) {var intervalID = window.setInterval(correct, time);},700);
}
})();