mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Fix issue when a layout changes and there's an ongoing transition
This commit is contained in:
parent
504ac9223a
commit
909ada9f18
@ -174,6 +174,7 @@ local function create()
|
|||||||
if t.in_progress_count == 0 then
|
if t.in_progress_count == 0 then
|
||||||
table.insert(t.urls, msg.url())
|
table.insert(t.urls, msg.url())
|
||||||
current_transition = t
|
current_transition = t
|
||||||
|
current_transition.id = transition_id
|
||||||
if #t.transitions > 0 then
|
if #t.transitions > 0 then
|
||||||
for i=1,#t.transitions do
|
for i=1,#t.transitions do
|
||||||
local transition = t.transitions[i]
|
local transition = t.transitions[i]
|
||||||
@ -206,7 +207,7 @@ local function create()
|
|||||||
transition.fn(transition.node, transition.node_data, transition.easing, 0, 0)
|
transition.fn(transition.node, transition.node_data, transition.easing, 0, 0)
|
||||||
end
|
end
|
||||||
if current_transition.in_progress_count > 0 then
|
if current_transition.in_progress_count > 0 then
|
||||||
finish_transition(message_id)
|
finish_transition(current_transition.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif message_id == monarch.TRANSITION.SHOW_IN
|
elseif message_id == monarch.TRANSITION.SHOW_IN
|
||||||
|
@ -2,11 +2,13 @@ local deftest = require "deftest.deftest"
|
|||||||
|
|
||||||
local test_monarch = require "test.test_monarch"
|
local test_monarch = require "test.test_monarch"
|
||||||
local test_callback_tracker = require "test.test_callback_tracker"
|
local test_callback_tracker = require "test.test_callback_tracker"
|
||||||
|
local test_transitions = require "test.test_transitions"
|
||||||
|
|
||||||
|
|
||||||
function init(self)
|
function init(self)
|
||||||
deftest.add(test_monarch)
|
deftest.add(test_monarch)
|
||||||
deftest.add(test_callback_tracker)
|
deftest.add(test_callback_tracker)
|
||||||
|
deftest.add(test_transitions)
|
||||||
deftest.run({
|
deftest.run({
|
||||||
coverage = { enabled = true },
|
coverage = { enabled = true },
|
||||||
pattern = "",
|
pattern = "",
|
||||||
|
46
test/test_transitions.lua
Normal file
46
test/test_transitions.lua
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
local cowait = require "test.cowait"
|
||||||
|
local mock_msg = require "test.msg"
|
||||||
|
local mock_gui = require "deftest.mock.gui"
|
||||||
|
local unload = require "deftest.util.unload"
|
||||||
|
local monarch = require "monarch.monarch"
|
||||||
|
local transitions = require "monarch.transitions.gui"
|
||||||
|
local easing = require "monarch.transitions.easings"
|
||||||
|
|
||||||
|
return function()
|
||||||
|
|
||||||
|
describe("transitions", function()
|
||||||
|
before(function()
|
||||||
|
mock_msg.mock()
|
||||||
|
mock_gui.mock()
|
||||||
|
transitions = require "monarch.transitions.gui"
|
||||||
|
end)
|
||||||
|
|
||||||
|
after(function()
|
||||||
|
mock_msg.unmock()
|
||||||
|
mock_gui.unmock()
|
||||||
|
unload.unload("monarch%..*")
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
it("should replay and immediately finish on layout change", function()
|
||||||
|
function dummy_transition(node, to, easing, duration, delay, cb)
|
||||||
|
print("dummy transition")
|
||||||
|
end
|
||||||
|
|
||||||
|
local node = gui.new_box_node(vmath.vector3(), vmath.vector3(100, 100, 0))
|
||||||
|
local duration = 2
|
||||||
|
local t = transitions.create(node)
|
||||||
|
.show_in(dummy_transition, easing.OUT, duration, delay or 0)
|
||||||
|
.show_out(dummy_transition, easing.IN, duration, delay or 0)
|
||||||
|
.back_in(dummy_transition, easing.OUT, duration, delay or 0)
|
||||||
|
.back_out(dummy_transition, easing.IN, duration, delay or 0)
|
||||||
|
|
||||||
|
t.handle(monarch.TRANSITION.SHOW_IN)
|
||||||
|
t.handle(hash("layout_changed"))
|
||||||
|
local messages = mock_msg.messages(msg.url())
|
||||||
|
assert(#messages == 1, "Expected one message to have been received")
|
||||||
|
assert(messages[1].message_id == monarch.TRANSITION.DONE, "Expected a TRANSITION.DONE message")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user