Safari pauses all animation on redirect / form submission

前端 未结 5 2015
野性不改
野性不改 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 19:01

    Write the code for animation before form submission. Perform form submission after some time. That is:

    var someData = 'foo'; //This value is irrelevant, just there for syntactical consistency.
    
    $("#link").on("click", function(e) {
    
    //Write your code for animation at first.
    $(this).animate({width: "100px", height: "100px", opacity: "0"}, 150);
    
    //write the code for form submission
    setTimeout(function() {
        var form = $("
    "); form.attr("action", "http://someurl.com"); var input = $(""); input.val(someData); form.append(input); $(document.body).append(form); form.submit(); }, 1000); });

提交回复
热议问题