3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 10:27:49 +02:00

Merge pull request #17 from britzl/resizefix

Replay transitions when the layout changes
This commit is contained in:
Björn Ritzl 2018-05-26 19:43:42 +02:00 committed by GitHub
commit 39628b75af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,6 +96,8 @@ function M.create(node)
local transitions = {} local transitions = {}
local current_transition = nil
local initial_data = {} local initial_data = {}
initial_data.pos = gui.get_position(node) initial_data.pos = gui.get_position(node)
initial_data.scale = gui.get_scale(node) initial_data.scale = gui.get_scale(node)
@ -114,6 +116,7 @@ function M.create(node)
local function start_transition(transition, url) local function start_transition(transition, url)
table.insert(transition.urls, url) table.insert(transition.urls, url)
if not transition.in_progress then if not transition.in_progress then
current_transition = transition
transition.in_progress = true transition.in_progress = true
transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function() transition.fn(node, initial_data, transition.easing, transition.duration, transition.delay or 0, function()
transition.in_progress = false transition.in_progress = false
@ -129,6 +132,12 @@ function M.create(node)
function instance.handle(message_id, message, sender) function instance.handle(message_id, message, sender)
if message_id == LAYOUT_CHANGED then if message_id == LAYOUT_CHANGED then
initial_data.pos = gui.get_position(node) initial_data.pos = gui.get_position(node)
-- replay the current transition if the layout changes
-- this will ensure that things are still hidden if they
-- were transitioned out
if current_transition then
current_transition.fn(node, initial_data, current_transition.easing, 0, 0)
end
else else
local transition = transitions[message_id] local transition = transitions[message_id]
if transition then if transition then