这个判断把我搞晕了
function animate (offset) { if (offset == 0) { return; } animated = true; var time = 300; var inteval = 10; var speed = offset/(time/inteval); var left = parseInt(list.style.left) + offset; var go = function (){ if ( (speed > 0 && parseInt(list.style.left) < left) || (speed < 0 && parseInt(list.style.left) > left)) { list.style.left = parseInt(list.style.left) + speed + 'px'; setTimeout(go, inteval); }else { list.style.left = left + 'px'; if(left>-200){ list.style.left = -600 * len + 'px'; } if(left<(-600 * len)) { list.style.left = '-600px'; } } } go();}
这是这节课下载来的代码,我怎么觉得if里的(speed > 0 && parseInt(list.style.left) < left) || (speed < 0 && parseInt(list.style.left) > left) 一直都是成立的怎么else跳出去的?
图片在第一个时parseInt(list.style.left)=-600,向左移animate(600); parseInt(list.style.left)<left = 0;满足条件,
图片在最后一个时parseInt(list.style.left)=-3000,向右animate(-600);parseInt(list.style.left)> left = -3600;也满足条件 ,什么情况下跳出这个判断条件?