Transitions with Monarch [SOLVED]

Hey there,

So, I’ve read the docs and scoured the forum here and tried out a bunch of things but there must be something super obvious escaping me because I can’t get transitions to work in Monarch. I don’t get any errors, and the screen (popup in this case) displays totally fine, but transitions don’t show. I’ll paste the code from the gui below – it’s all just basically copy+paste from the docs. I’m sure there’s just a box I didn’t tick somewhere or something not right, but I just can’t figure it out. Thanks!

local monarch = require "monarch.monarch"
local transitions = require "monarch.transitions.gui"

function init(self)
    local data = monarch.data("alert")

    -- Reposition the root node
    local root_node = gui.get_node("root")
    gui.set_position(root_node, vmath.vector3(data.x, data.y, 0))

    -- Set the title and content text
    local title_node = gui.get_node("title")
    local content_node = gui.get_node("content")

    gui.set_text(title_node, data.title)
    gui.set_text(content_node, data.content)

    local transition = transitions.create(gui.get_node("root"))
    .show_in(transitions.slide_in_right, gui.EASING_OUTQUAD, 0.6, 0)
    .show_out(transitions.slide_out_left, gui.EASING_INQUAD, 0.6, 0)
    .back_in(transitions.slide_in_left, gui.EASING_OUTQUAD, 0.6, 0)
    .back_out(transitions.slide_out_right, gui.EASING_INQUAD, 0.6, 0)

    monarch.on_transition("alert", transition)
    msg.post(".", "acquire_input_focus")
end

function final(self)
end

function update(self, dt)
end

function on_message(self, message_id, message, sender)
    monarch.on_message(message_id, message, sender)
    -- you can also check when a transition has completed:
    if message_id == monarch.TRANSITION.DONE and message.transition == monarch.TRANSITION.SHOW_IN then
        print("Show in done!")
    end
end

function on_input(self, action_id, action)
end

function on_reload(self)
end

Can you please create an issue in the Monarch repo. Please include a project where this issue can be reproduced.

No problem. Filed! https://github.com/britzl/monarch/issues/99

One thing that’s caught me out a few times is that transitions don’t work if any of the nodes part of the transition are disabled. Could be worth checking!

Alright, I think I found the issue. I opened a PR with a fix. Line 512 of monarch.lua:

screen.transition_url = screen.factory_ids[screen.transition_id]

…but earlier on line 325, it’s set to nil because screen.transition_id is deprecated.

PR here: #100

ps. I am not at all familiar with the monarch source so this might not be the best way to fix this. I just did this because it was low-touch and maintained the “backwards compat” for that deprecated functionality and fixed it moving forward at least for me.

1 Like