|
1 | 1 | local monarch = require "monarch.monarch"
|
| 2 | +local easings = require "monarch.transitions.easings" |
2 | 3 |
|
3 | 4 | local M = {}
|
4 | 5 |
|
@@ -198,4 +199,60 @@ function M.create(node)
|
198 | 199 | return instance
|
199 | 200 | end
|
200 | 201 |
|
| 202 | + |
| 203 | +--- Create transition where the screen slides in from the right when shown and out |
| 204 | +-- to the left when hidden (and the reverse when going back) |
| 205 | +-- @param node |
| 206 | +-- @param duration |
| 207 | +-- @param delay Optional. Defaults to 0 |
| 208 | +-- @param easing Optional. A constant from monarch.transitions.easing |
| 209 | +-- @return Transition instance |
| 210 | +function M.in_right_out_left(node, duration, delay, easing) |
| 211 | + assert(node, "You must provide a node") |
| 212 | + assert(duration, "You must provide a duration") |
| 213 | + easing = easing or easings.QUAD() |
| 214 | + return M.create(node) |
| 215 | + .show_in(M.slide_in_right, easing.OUT, duration, delay or 0) |
| 216 | + .show_out(M.slide_out_left, easing.IN, duration, delay or 0) |
| 217 | + .back_in(M.slide_in_left, easing.OUT, duration, delay or 0) |
| 218 | + .back_out(M.slide_out_right, easing.IN, duration, delay or 0) |
| 219 | +end |
| 220 | + |
| 221 | + |
| 222 | +function M.in_left_out_right(node, duration, delay, easing) |
| 223 | + assert(node, "You must provide a node") |
| 224 | + assert(duration, "You must provide a duration") |
| 225 | + easing = easing or easings.QUAD() |
| 226 | + return M.create(node) |
| 227 | + .show_in(M.slide_in_left, easing.OUT, duration, delay or 0) |
| 228 | + .show_out(M.slide_out_right, easing.IN, duration, delay or 0) |
| 229 | + .back_in(M.slide_in_right, easing.OUT, duration, delay or 0) |
| 230 | + .back_out(M.slide_out_left, easing.IN, duration, delay or 0) |
| 231 | +end |
| 232 | + |
| 233 | + |
| 234 | +function M.in_right_out_right(node, duration, delay, easing) |
| 235 | + assert(node, "You must provide a node") |
| 236 | + assert(duration, "You must provide a duration") |
| 237 | + easing = easing or easings.QUAD() |
| 238 | + return M.create(node) |
| 239 | + .show_in(M.slide_in_right, easing.OUT, duration, delay or 0) |
| 240 | + .show_out(M.slide_out_right, easing.IN, duration, delay or 0) |
| 241 | + .back_in(M.slide_in_right, easing.OUT, duration, delay or 0) |
| 242 | + .back_out(M.slide_out_right, easing.IN, duration, delay or 0) |
| 243 | +end |
| 244 | + |
| 245 | + |
| 246 | +function M.in_left_out_left(node, duration, delay, easing) |
| 247 | + assert(node, "You must provide a node") |
| 248 | + assert(duration, "You must provide a duration") |
| 249 | + easing = easing or easings.QUAD() |
| 250 | + return M.create(node) |
| 251 | + .show_in(M.slide_in_left, easing.OUT, duration, delay or 0) |
| 252 | + .show_out(M.slide_out_left, easing.IN, duration, delay or 0) |
| 253 | + .back_in(M.slide_in_left, easing.OUT, duration, delay or 0) |
| 254 | + .back_out(M.slide_out_left, easing.IN, duration, delay or 0) |
| 255 | +end |
| 256 | + |
| 257 | + |
201 | 258 | return M
|
0 commit comments