Safari pauses all animation on redirect / form submission

前端 未结 5 2014
野性不改
野性不改 2021-02-01 18:08

I have an animation that triggers when a link is clicked. It is a jQuery animation that enlarges a div then fades out. To ensure speed, at the exact same time that the link is c

5条回答
  •  被撕碎了的回忆
    2021-02-01 18:53

    What I have found is that Safari actually pauses all animations as soon as the pagehide event is fired, whenever the browser begins loading a new page.

    After pagehide, it won't even allow CSS changes such as showing a spinner that was previously hidden.

    In order to show the spinner before the pagehide event fires, I needed to add listeners for a[href] clicks and ajaxComplete events.

    My guess is that Safari does this to enhance performamce by focusing all available CPU and GPU power to the rendering of the next page.

    I think this is a bit extreme, and unfortunate for UX where in many mobile web applications we use spinner animations at page unload to show the user something is happening during the few seconds while a new page is being fetched.

    I have so far not found a way to preserve motion animation during page unload; at best the spinner appears frozen but still shows up... a possible workaround is to use a static message to indicate it's "Loading..."

提交回复
热议问题