-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappBase.coffee
82 lines (75 loc) · 1.59 KB
/
appBase.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
exports.appBase = class appBase
constructor: (@layers, @header, @menu) ->
# Check for the right number of screen / menu items
if @layers.length != @menu.children.length
print "Must have the same size of layers and menu"
# Custom transition
transitionLeft = (nav, layerA, layerB, overlay) ->
transition =
layerA:
show:
x: 0
opacity: 1
hide:
x: -100
opacity: 0
options:
time: 0.1
layerB:
show:
x: 0
opacity: 1
options:
time: 0.3
hide:
x: 100
opacity: 0
transitionRight = (nav, layerA, layerB, overlay) ->
transition =
layerA:
show:
x: 0
opacity: 1
hide:
x: 100
opacity: 0
options:
time: 0.1
layerB:
show:
x: 0
opacity: 1
options:
time: 0.3
hide:
x: -100
opacity: 0
# Create FlowComponent
flow = new FlowComponent
backgroundColor: "#ffffff"
flow.header = @header
flow.footer = @menu
flow.showNext(@layers[0])
# Create Menu
menuIndex = 0
menuPrevious = 1
for name, layer of @menu.children
layer.mIndex = menuIndex
layer.saturate = 0
layer.states.on =
saturate: 100
animationOptions:
time: 0.7
layer.onTap ->
switchMenu(this.mIndex)
menuIndex++
switchMenu = (i) =>
if(i != menuPrevious)
@menu.children[menuPrevious].stateCycle("default")
@menu.children[i].stateCycle()
if i > menuPrevious
flow.transition(@layers[i], transitionLeft)
else
flow.transition(@layers[i], transitionRight)
menuPrevious = i
switchMenu(0)