When a link is clicked, I have an animation that enlarges a div and fades out using jQuery. At the same time the link is clicked, a redirect is triggered by submitting a form to ensure speed. The redirect cannot be placed in the success function of jQuery's animate(). This process works smoothly on Chrome, Firefox, and IE where the animation plays and redirects if the page loads before the animation finishes.
However, on Safari (mainly testing on iPad), clicking a link causes the page to appear frozen and the animation fails to execute. Additionally, GIFs on the screen pause when links are clicked while they are still animating. Suggestions online include setting a timeout, applying styling, then submitting, but this doesn't resolve the freezing issue especially with animations involved.
To illustrate my approach, here is some example code (not tested and may contain errors):
var someData = 'foo';
$("#link").on("click", function() {
var form = $("<form method='POST'></form>");
form.attr("action", "http://someurl.com");
var input = $("<input type='hidden'/>");
input.val(someData);
form.append(input);
$(document.body).append(form);
form.submit();
//Short animation for the remainig life of the current page after form submission
$(this).animate({width: "100px", height: "100px", opacity: "0"}, 150);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div id="link" style="width: 100px; height: 100px; background-color: #FFF">Click Me</div>
I am looking for a solution to prevent Safari from freezing when loading a new page or following a link, allowing the current page to continue updating. This seems to be a problem specifically with Safari, as it hasn't been widely reported across the web, especially concerning CSS style animations like in my scenario. Any help would be greatly appreciated!
Thank you!