The solution of animate animation accumulation in jquery _jquery

Source: Internet
Author: User
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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.