2017-10-07 04:27:41 +00:00
|
|
|
local Tween = require('ui.tween')
|
|
|
|
|
|
|
|
local Transition = { }
|
|
|
|
|
|
|
|
function Transition.slideLeft(args)
|
2019-02-06 04:03:57 +00:00
|
|
|
local ticks = args.ticks or 10
|
2018-01-24 22:39:38 +00:00
|
|
|
local easing = args.easing or 'outQuint'
|
|
|
|
local pos = { x = args.ex }
|
|
|
|
local tween = Tween.new(ticks, pos, { x = args.x }, easing)
|
2019-01-30 20:11:41 +00:00
|
|
|
|
|
|
|
args.canvas:move(pos.x, args.canvas.y)
|
2017-10-07 04:27:41 +00:00
|
|
|
|
2019-02-06 04:03:57 +00:00
|
|
|
return function()
|
2018-01-24 22:39:38 +00:00
|
|
|
local finished = tween:update(1)
|
2019-01-30 20:11:41 +00:00
|
|
|
args.canvas:move(math.floor(pos.x), args.canvas.y)
|
|
|
|
args.canvas:dirty()
|
2018-01-24 22:39:38 +00:00
|
|
|
return not finished
|
|
|
|
end
|
2017-10-07 04:27:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Transition.slideRight(args)
|
2019-02-06 04:03:57 +00:00
|
|
|
local ticks = args.ticks or 10
|
2018-01-24 22:39:38 +00:00
|
|
|
local easing = args.easing or'outQuint'
|
2019-01-30 20:11:41 +00:00
|
|
|
local pos = { x = -args.canvas.width }
|
|
|
|
local tween = Tween.new(ticks, pos, { x = 1 }, easing)
|
|
|
|
|
|
|
|
args.canvas:move(pos.x, args.canvas.y)
|
2017-10-07 04:27:41 +00:00
|
|
|
|
2019-02-06 04:03:57 +00:00
|
|
|
return function()
|
2018-01-24 22:39:38 +00:00
|
|
|
local finished = tween:update(1)
|
2019-01-30 20:11:41 +00:00
|
|
|
args.canvas:move(math.floor(pos.x), args.canvas.y)
|
|
|
|
args.canvas:dirty()
|
2018-01-24 22:39:38 +00:00
|
|
|
return not finished
|
|
|
|
end
|
2017-10-07 04:27:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Transition.expandUp(args)
|
2018-01-24 22:39:38 +00:00
|
|
|
local ticks = args.ticks or 3
|
|
|
|
local easing = args.easing or 'linear'
|
|
|
|
local pos = { y = args.ey + 1 }
|
|
|
|
local tween = Tween.new(ticks, pos, { y = args.y }, easing)
|
2017-10-07 04:27:41 +00:00
|
|
|
|
2019-01-30 20:11:41 +00:00
|
|
|
args.canvas:move(args.x, pos.y)
|
2017-10-07 04:27:41 +00:00
|
|
|
|
2019-02-06 04:03:57 +00:00
|
|
|
return function()
|
2018-01-24 22:39:38 +00:00
|
|
|
local finished = tween:update(1)
|
2019-01-30 20:11:41 +00:00
|
|
|
args.canvas:move(args.x, math.floor(pos.y))
|
|
|
|
args.canvas:dirty()
|
2018-01-24 22:39:38 +00:00
|
|
|
return not finished
|
|
|
|
end
|
2017-10-07 04:27:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return Transition
|