Skip to content

Commit 1dec704

Browse files
committed
Delay reset of timestep when going back from popup
Fixes #84
1 parent 9764c68 commit 1dec704

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

monarch/monarch.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ local function back_out(screen, next_screen, wait_for_transition, cb)
650650
change_context(screen)
651651
release_input(screen, next_screen)
652652
focus_lost(screen, next_screen)
653+
transition(screen, M.TRANSITION.BACK_OUT, { next_screen = next_screen and next_screen.id }, wait_for_transition)
653654
if next_screen and screen.popup then
654655
reset_timestep(next_screen)
655656
end
656-
transition(screen, M.TRANSITION.BACK_OUT, { next_screen = next_screen and next_screen.id }, wait_for_transition)
657657
screen.visible = false
658658
unload(screen)
659659
active_transition_count = active_transition_count - 1
@@ -921,9 +921,20 @@ function M.back(data, cb)
921921
if data then
922922
top.data = data
923923
end
924-
back_in(top, screen, DO_NOT_WAIT_FOR_TRANSITION, function()
925-
back_out(screen, top, WAIT_FOR_TRANSITION, back_cb)
926-
end)
924+
-- if the screen we are backing out from is a popup and the screen we go
925+
-- back to is not a popup we need to let the popup completely hide before
926+
-- we start working on the screen we go back to
927+
-- we do this to ensure that we do not reset the times step of the screen
928+
-- we go back to until it is no longer obscured by the popup
929+
if screen.popup and not top.popup then
930+
back_out(screen, top, WAIT_FOR_TRANSITION, function()
931+
back_in(top, screen, WAIT_FOR_TRANSITION, back_cb)
932+
end)
933+
else
934+
back_in(top, screen, DO_NOT_WAIT_FOR_TRANSITION, function()
935+
back_out(screen, top, WAIT_FOR_TRANSITION, back_cb)
936+
end)
937+
end
927938
else
928939
back_out(screen, top, WAIT_FOR_TRANSITION, back_cb)
929940
end

0 commit comments

Comments
 (0)