How transitions work in Monarch
masterBy default, screen navigation in Monarch is instant. You can add optional transitions to make navigation smoother. When a transition is defined for a screen, Monarch will wait for the transition to complete before proceeding with the navigation sequence.
Transitions are configured using monarch.on_transition(screen_id, fn). The callback function fn must accept (message_id, message, sender) as arguments. The message_id determines which type of transition to start:
monarch.TRANSITION_SHOW_INmonarch.TRANSITION_SHOW_OUTmonarch.TRANSITION_BACK_INmonarch.TRANSITION_BACK_OUT
Crucial: Once your transition animation is finished, you must send a monarch.TRANSITION_DONE message back to the sender to notify Monarch that it can continue the navigation.
monarch.on_transition("my_screen", function(message_id, message, sender)
-- Start animation based on message_id
-- ... animation logic ...
-- When finished:
sender.send(monarch.TRANSITION_DONE, { transition = message_id })
end)