Safari pauses all animation on redirect / form submission

前端 未结 5 2022
野性不改
野性不改 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:07

    You could use a setTimeout to go to the link after the animation.

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

提交回复
热议问题