-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
95 lines (79 loc) · 2.21 KB
/
app.js
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
//
// Groupon-esk Sliding Pages w/Navbar animation
//
var SlidingPageController = require('com_mfogg_sliding_page_controller');
//
// These are the initial pages that are loaded in
//
// "title" = Nav area text
// "page" = The view container that will act as that page in the slider
//
var pages = [
{ title: "Page One",
page: Ti.UI.createView({ backgroundColor:'#eee', top: 0, left: 0, right: 0, bottom: 0 })
},
{ title: "Page Two",
page: Ti.UI.createView({ backgroundColor:'#ddd', top: 0, left: 0, right: 0, bottom: 0 })
},
{ title: "Page Three",
page: Ti.UI.createView({ backgroundColor:'#ccc', top: 0, left: 0, right: 0, bottom: 0 })
}
];
//
// Initialize the controller
//
// "initialPage" = Where we are starting :)
// "disableBounce" = Incase you want to allow bounce to scroll past the edges on the left/right side
// "nav" = Some optional params for the navigation bar. NOTE: I plan on adding more here
// "pages" = Initial pages
//
var sliding_page_controller = new SlidingPageController({
initialPage: 1,
disableBounce: true,
nav: {
backgroundColor: "#82B548",
color: "#fff",
height: 70
},
pages: pages
});
//
// Callback that is fired ("pagechange") after successfully switching pages
//
sliding_page_controller.addEventListener("pagechange", function(e){
Ti.API.info("Scrolled to page: "+e.currentPage);
});
//
// A button that allows you to add a custom page after initialization
// NOTE: There is no "removePage" function yet... in due time :)
// If you need this ASAP, let me know and I'll add it in (I haven't needed it yet)
//
var button = Ti.UI.createView({
height: 60,
width: 60,
bottom: 10,
borderRadius: 30,
backgroundColor: "#82B548"
});
button.addEventListener('click', function(e){
//
// Add the new page!
//
// Set "scrollTo" to false if you don't want it to slide to this cool new page
//
sliding_page_controller.addPage({
title: "Page",
page: Ti.UI.createView({ backgroundColor:'#bbb', top: 0, left: 0, right: 0, bottom: 0 }),
scrollTo: true
});
});
//
// Now create the actual page :)
//
var win = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
win.add(sliding_page_controller);
win.add(button);
win.open();