Error with Javascript / Jquery timing in inactive tabs

亡梦爱人 提交于 2019-12-21 13:02:22

问题


I have recently took on the task of building a animation in Javascript / jQuery. The animation consists of a circle moving around the london tube map. Each time it passes a station, the station name is underlined.

I am still working on refining it and noticed that when the tab is inactive if messes the timing of the sequence when coming back to the page. Because I am embedding it inside an iframe It does not seem to work when I use $(window).focus() or $(window).blur().

I have animated the circle using jQuery animate function and simply made the opacity 0 on all of the lines under the text and put delays on them for them to animate the opacity to 100. I have put a link below to display the animation as it is. Still issues with the animation which I currently tweaking but I not sure how to fix the inactive tab problem. Any help woud be great.

withoutframe: http://www.gbutlercreative.co.uk/london/index.html

with frame http://www.gbutlercreative.co.uk/london/frame.html


回答1:


I think you could use animate callback function, but you will have to recode all your logic:

$(".icon")
  .animate({left:'+=23px',top:'+=23px'},500,'linear',function(){$(".Chesham").animate({opacity:1},10);})
  .animate({left:'+=22px'},500,'linear',function(){$(".Chalfont").animate({opacity:1},10);})

Do the same for all.



来源:https://stackoverflow.com/questions/16399057/error-with-javascript-jquery-timing-in-inactive-tabs

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