-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.coffee
130 lines (110 loc) · 2.34 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
# initial setup
flowComp = new FlowComponent
flowComp.header = hdr
flowComp.footer = tabBar
flowComp.backgroundColor = '#FFF'
flowComp.showNext(home)
flowComp.scroll.directionLock = true
# scanner setup
scanner = new VideoLayer
video: "images/movie.MOV"
backgroundColor: "black"
size: Screen.size
scanner.parent = videoContainer
scanner.sendToBack()
# simulate barcode recognition
Events.wrap(scanner.player).on "ended", ->
scannerTarget_1.stroke = "green"
scanner.opacity = 0.8
Utils.delay 1, ->
flowComp.showOverlayTop(scannerResults)
# click handler transition for tab bar
Scale = () ->
transition =
layerA:
show:
x: 0
y: 0
hide:
x: 0
y: 668
options:
time:.2
curve: Spring(damping: .5)
layerB:
show:
x: 0
y: 0
options:
time:.2
curve: Spring(damping: .8)
hide:
x: 0
y: 668
# states
hdr.states =
hide:
y: -68
animationOptions:
time: .3
curve: Bezier.easeInOut
tabBar.states =
hide:
y: 668
animationOptions:
time: .3
curve: Bezier.easeInOut
# click handlers
profile_btn.onClick ->
flowComp.transition(profile, Scale)
home_btn.onClick ->
flowComp.transition(home, Scale)
flowComp.scroll.directionLock = true
deals_btn.onClick ->
flowComp.transition(deals, Scale)
cart_btn.onClick ->
flowComp.transition(cart, Scale)
scan_btn.onClick ->
scanner.player.play()
flowComp.showOverlayBottom(videoContainer)
Icon.onClick ->
flowComp.showOverlayLeft(menuOverlay)
menuOverlay.onClick ->
flowComp.showPrevious()
cancel_btn.onClick ->
flowComp.showPrevious()
scanner.player.load()
scannerResults.onClick ->
flowComp.transition(home, Scale)
# header / footer peek-a-boo
flowComp.onScroll ->
if flowComp.scroll.direction is "down"
tabBar.animate "hide"
hdr.animate "hide"
if flowComp.scroll.direction is "up"
tabBar.animate "default"
hdr.animate "default"
# home carousel
carousel = new PageComponent
width: 375
height: 216
parent: home
directionLock: true
scrollVertical: false
x: 0
y: 0
z:100
slide1 = new Layer
parent: carousel.content
image: "images/slide1.png"
size: carousel.size
slide2 = new Layer
parent: carousel.content
image: "images/slide2.png"
size: carousel.size
slide3 = new Layer
parent: carousel.content
image: "images/slide3.png"
size: carousel.size
carousel.addPage(slide2, "right")
carousel.addPage(slide3, "right")