mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 10:27:49 +02:00
Added fade in/out transition
This commit is contained in:
parent
07eacc7a5f
commit
bc4260d72a
@ -162,6 +162,8 @@ The predefined transitions provided by ```monarch.transitions.gui``` are:
|
|||||||
* ```slide_out_bottom```
|
* ```slide_out_bottom```
|
||||||
* ```scale_in```
|
* ```scale_in```
|
||||||
* ```scale_out```
|
* ```scale_out```
|
||||||
|
* ```fade_in``` - Set node alpha to fully transparent (i.e. 0.0) and fade to fully opaque (i.e. 1.0)
|
||||||
|
* ```fade_out``` - Set node alpha to fully opaque (i.e. 1.0) and fade to fully transparent (i.e. 0.0)
|
||||||
|
|
||||||
Additionally there's functionality to create a full set of transitions for common transition styles:
|
Additionally there's functionality to create a full set of transitions for common transition styles:
|
||||||
|
|
||||||
@ -169,6 +171,7 @@ Additionally there's functionality to create a full set of transitions for commo
|
|||||||
* ```transitions.in_left_out_right(node, duration, [delay], [easing])```
|
* ```transitions.in_left_out_right(node, duration, [delay], [easing])```
|
||||||
* ```transitions.in_left_out_left(node, duration, [delay], [easing])```
|
* ```transitions.in_left_out_left(node, duration, [delay], [easing])```
|
||||||
* ```transitions.in_right_out_right(node, duration, [delay], [easing])```
|
* ```transitions.in_right_out_right(node, duration, [delay], [easing])```
|
||||||
|
* ```transitions.fade_in_out(node, duration, [delay], [easing])```
|
||||||
|
|
||||||
**PARAMETERS**
|
**PARAMETERS**
|
||||||
* ```node``` (node) - Gui node to animate.
|
* ```node``` (node) - Gui node to animate.
|
||||||
|
@ -6,7 +6,7 @@ function init(self)
|
|||||||
|
|
||||||
gui.set_text(gui.get_node("timestamp"), os.date())
|
gui.set_text(gui.get_node("timestamp"), os.date())
|
||||||
|
|
||||||
self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
|
self.transition = transitions.fade_in_out(gui.get_node("root"), 0.6, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_input(self, action_id, action)
|
function on_input(self, action_id, action)
|
||||||
|
@ -88,6 +88,22 @@ function M.scale_out(node, from, easing, duration, delay, cb)
|
|||||||
gui.animate(node, gui.PROP_SCALE, ZERO_SCALE, easing, duration, delay, cb)
|
gui.animate(node, gui.PROP_SCALE, ZERO_SCALE, easing, duration, delay, cb)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.fade_out(node, from, easing, duration, delay, cb)
|
||||||
|
local to = gui.get_color(node)
|
||||||
|
to.w = 1
|
||||||
|
gui.set_color(node, to)
|
||||||
|
to.w = 0
|
||||||
|
gui.animate(node, gui.PROP_COLOR, to, easing, duration, delay, cb)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.fade_in(node, from, easing, duration, delay, cb)
|
||||||
|
local to = gui.get_color(node)
|
||||||
|
to.w = 0
|
||||||
|
gui.set_color(node, to)
|
||||||
|
to.w = 1
|
||||||
|
gui.animate(node, gui.PROP_COLOR, to, easing, duration, delay, cb)
|
||||||
|
end
|
||||||
|
|
||||||
--- Create a transition for a node
|
--- Create a transition for a node
|
||||||
-- @return Transition instance
|
-- @return Transition instance
|
||||||
function M.create(node)
|
function M.create(node)
|
||||||
@ -255,4 +271,16 @@ function M.in_left_out_left(node, duration, delay, easing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.fade_in_out(node, duration, delay, easing)
|
||||||
|
assert(node, "You must provide a node")
|
||||||
|
assert(duration, "You must provide a duration")
|
||||||
|
easing = easing or easings.QUAD()
|
||||||
|
return M.create(node)
|
||||||
|
.show_in(M.fade_in, easing.OUT, duration, delay or 0)
|
||||||
|
.show_out(M.fade_out, easing.IN, duration, delay or 0)
|
||||||
|
.back_in(M.fade_in, easing.OUT, duration, delay or 0)
|
||||||
|
.back_out(M.fade_out, easing.IN, duration, delay or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Loading…
x
Reference in New Issue
Block a user