Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message monarch.TRANSITION.DONE not triggered #106

Open
baochungit opened this issue Jan 17, 2024 · 4 comments
Open

message monarch.TRANSITION.DONE not triggered #106

baochungit opened this issue Jan 17, 2024 · 4 comments

Comments

@baochungit
Copy link

Hi, I've just checked a custom transition by the following code but it seems SHOW_IN not be done or missing the message

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

function init(self)
	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("foobar", transition)
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
@britzl
Copy link
Owner

britzl commented Jan 20, 2024

And you are calling monarch.show("foobar") somewhere?

@baochungit
Copy link
Author

Yes, from another screen. Another thing I realised that when I call monarch.hide("foobar"), it seems
.back_out(...) works (has animation) while I expect .show_out(...) will do animation.

@britzl
Copy link
Owner

britzl commented Jan 22, 2024

Ah, yes, I see now. The documentation and code doesn't match. I think I can add support at least for sending a transition done message when a screen is shown.

@britzl
Copy link
Owner

britzl commented Jan 22, 2024

Or actually, I think it is better to use monarch.add_listener()

function init(self)
    monarch.add_listener()
end

function on_message(self, message_id, message, sender)
	...
	if message_id == monarch.SCREEN_TRANSITION_IN_FINISHED and message.screen == hash("window1") then
		print("Window1 is now shown")
	end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants