Yesterday, a classmate to me for help, said to do a simple animation effect, is the picture automatically play around
Copy Code code as follows:
<span style= "White-space:pre" > </span>/* Seamless Focus Map * *
var _left = 770;
var left =-_left;//-770
function slideimg () {
if (left = = -3080 | | left = = 0) {
_left =-_left;
}
$ ('. Slidepics '). Animate ({' Left ': Left + ' px '},1000);
left = left-_left;
Tim = settimeout (slideimg,5000);
}
Slideimg ();
Copy Code code as follows:
I looked, quite simple, at first glance, no problem ah. Then he said the odd question that bothered him for one months, he said that the window at the end is OK, but to minimize the window or browse other windows when the words appear fast playback, after a while normal (ie is no problem, Chrome has problems, Firefox also no problem).
Since I have never experienced this problem before, I also thought for more than half an hour, did not finish, and then turned over the previous notes, with the answer, that settimeout use will produce animation queue, it is possible in the Chrome browser window is not at the forefront of the animation queue to generate accumulation, When the return to the front end of a sudden burst out, and then think of jquery in the Stop method, the method is to stop all animations on this element. Sure enough, it's OK to add.
Copy Code code as follows:
<span style= "White-space:pre" > </span>/* Seamless Focus Map * *
var _left = 770;
var left =-_left;//-770
function slideimg () {
if (left = = -3080 | | left = = 0) {
_left =-_left;
}
$ ('. Slidepics '). Stop (). Animate ({' Left ': Left + ' px '},1000);
left = left-_left;
Tim = settimeout (slideimg,5000);
}
Slideimg ();