Jquery Animate stop when i change the browser tab

限于喜欢 提交于 2019-12-11 01:59:54

问题


I have a crazy problem in my portfolio: http://hericdk.com

I made a simple animation with jquery, an animation with a space ship flying, and then it appears my work, this idea is nice, everyone liked, but the problem is that for some strange reason, when I click to see my projects and the ship starts to fly, if I change the browser tab and then return, all the background animation works normally.. but the animation remains of the ship is still waiting for the next action of the animation until I return to the tab of my portfolio.

I'll put here the code of the animation of the space ship for you all understand.

$('#spaceship a').click(function(){
    $('#spaceship').spState(2).sprite({fps: 9, no_of_frames: 12});
    $('#space').stop().delay(3000).animate({'top':'0px'},9000,'easeInOutQuad');

$('#spaceship').animate({'top':'150px','left':'55%'},3000,'easeInOutExpo').delay(200)
    .animate({'top':'350px','left':'65%'},2000,'easeInOutExpo').delay(100)
    .animate({'top':'-400px','left':'65%'},1300,'easeInBack').delay(100)
    .animate({'top':'-400px','left':'88%'},300,'easeInBack').delay(3000)
    .animate({'top':$(window).height()-305+'px','left':'88%'},4000,'easeOutQuad',function(){
    $('#spaceship').spState(1).spStop(true);


    });// spaceship launch

    return false;       
}); //spaceship animation

来源:https://stackoverflow.com/questions/10955455/jquery-animate-stop-when-i-change-the-browser-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!