jquery animate doesn't work on ipad after sleep/resume

最后都变了- 提交于 2019-12-12 04:52:03

问题


I'm seeing a strange behaviour on ipad with ios 8.1. I have an html/js app where I use jquery animation for transitions. I use both animation of div position as well as fade in/out effects. Here's part of a simple example:

$in = $('#newdiv');
$in.css({position: 'absolute', left: "1024px", top: "0px"});
$in.removeClass('hidden');
$in.animate({left: tx, top: ty}, 400);

This works perfectly fine - up to a point. If, while the app is open, I press the "power" button to put the ipad to sleep and then wake it up again (power button, slide, enter unlock code), the animation doesn't work any more.

I connected the ipad to my mac and stepped through the code in a debugger - every line is executed correctly, but the animation simply doesn't animate - at all.

The same happens to the fadeIn/fadeOut animation.

Here's a very simple jsfiddle demonstrating the problem.

Note that this wasn't happening on the older version of ios before I updated my ipad to ios 8.1.

What am I missing?

UPDATE: this only seems to affect the app when running from home screen icon - when run inside the safari, everything works as expected.


回答1:


After spending a lot of time investigating this, it seems the issue is with the ipad/safari and not the jquery. I create a minimal test without jquery and using css3 transitions instead of jquery animate - and the issue is still present. I asked another question pertaining to the CSS transition.

I also logged it as a bug with Apple.



来源:https://stackoverflow.com/questions/27065545/jquery-animate-doesnt-work-on-ipad-after-sleep-resume

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