Complete_function not calling if the same animation starts immediately

I want to simulate card-flipping animation using this script:

local function rotateCard()
	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_INCIRC, 0.4, 0, function ()
		print("flipped")
		msg.post("#icon", "enable")
	end)
	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_OUTCIRC, 0.3, 0.45)
end

It works fine, but I must play the second animation with more delay.
I want to play the second animation immediately after the first animation is done i.e. with a 0.4-second delay. but in this case complete_function not calling. I must play the second animation at least 0.05 seconds later to "complete_function " work.

Have you tried:

    local function rotateCard()
        	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_INCIRC, 0.4, 0,
            function ()
        		print("flipped")
        	    msg.post("#icon", "enable")
        	    go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_OUTCIRC, 0.3)
        	end)
    end
3 Likes

You cannot have more than one animation on a property (e.g “scale.x”) at the same time.
So, you’ll cancel the first animation and replace it with the second one.
This is by design.

What @roccosaienz suggested is our recommended approach to chain multiple animations together, by using the complete-function.

3 Likes