/
app.coffee
155 lines (124 loc) · 2.96 KB
/
app.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
items = [
"All Deals",
"New Deals",
"Food & Drink",
"Events & Activities",
"Beauty & Spas",
"Health & Fitness",
"Home & Garden",
"Automotive",
"Shopping"
]
firstNavItem = null
itemContainer = new View
width: 640
clip: false
# ANIMATE ON LOAD
items.map (item, index) ->
itemView = new View
superView: itemContainer
width: 640
height: 88
x: 0
y: 1000 + index * 88
opacity: 0
clip: false
class: 'framer list'
firstNavItem = itemView if index is 0
itemView.style =
borderBottom: "1px solid rgba(0,0,0,.2)"
lineHeight: "#{itemView.height}px"
paddingLeft: "20px"
cursor: "pointer"
backgroundColor: "#f0f0f0"
if index > 1
itemView.html = "#{item} <span></span>"
else
itemView.html = "#{item}"
utils.delay index * 30, ->
itemView.animate
properties:
y: 216 + index * 88
opacity: 1
curve: "spring(500,30,800)"
# LOAD SUB ITEMS
itemView.on Events.TouchStart, () ->
# IF NOT FIRST TWO ITEMS IN LIST
if index > 0 && itemView.y != 216
originalPosition = itemView.y
moveTop = new Animation
view: itemView
properties:
y: 216
curve: "ease-out"
time: 300
itemView.html = "#{item} <span class='close'></span>"
moveTop.start()
utils.delay(100,showSub)
# MANUAL REVERSE
itemView.on Events.TouchStart, (event) ->
itemView.html = "#{item} <span></span>"
moveBack = new Animation
view: itemView
properties:
y: originalPosition
curve: "ease-out"
time: 300
moveBack.start()
hideSub()
# SUB ITEMS
subItems = [
"Sub Cat One (32)",
"Sub Cat Two (14)",
"Sub Cat Three (21)",
"Sub Cat Four (11)",
"Sub Cat Five (23)",
"Sub Cat Six (5)",
"Sub Cat Seven (14)",
"Sub Cat Eight (24)",
]
subItemContainer = new View
properties:
y: 1136
clip: false
hideSub = () ->
subItemContainer.animate
properties:
opacity: 0
curve: "ease-out"
time: 300
subItemContainer.destroy()
showSub = () ->
subItemContainer = new View
properties:
y: 1136
width: 640
clip: false
style:
backgroundColor: "#fafafa"
subItems.map (item, index) ->
subItemView = new View
superView: subItemContainer
width: 640
height: 88
x: 640
y: 304 + index * 88
opacity: 0
clip: true
class: 'framer list'
subItemView.style =
borderBottom: "1px solid rgba(0,0,0,.2)"
lineHeight: "#{subItemView.height}px"
color: "#75787b"
paddingLeft: "40px"
cursor: "pointer"
backgroundColor: "#fafafa"
subItemView.html = "#{item}"
utils.delay index * 30, ->
subItemView.animate
properties:
x: 0
opacity: 1
curve: "spring(400,30,800)"
subItemView.on Events.TouchStart, () ->
alert "Load Sub-Category"