forked from mcasimir/mobile-angular-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
130 lines (114 loc) · 4.44 KB
/
demo.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
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
var app = angular.module('MobileAngularUiExamples', [
"ngRoute",
"ngTouch",
"mobile-angular-ui"
]);
app.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/', {templateUrl: "home.html"});
$routeProvider.when('/scroll', {templateUrl: "scroll.html"});
$routeProvider.when('/toggle', {templateUrl: "toggle.html"});
$routeProvider.when('/tabs', {templateUrl: "tabs.html"});
$routeProvider.when('/accordion', {templateUrl: "accordion.html"});
$routeProvider.when('/overlay', {templateUrl: "overlay.html"});
$routeProvider.when('/forms', {templateUrl: "forms.html"});
$routeProvider.when('/carousel', {templateUrl: "carousel.html"});
});
app.service('analytics', [
'$rootScope', '$window', '$location', function($rootScope, $window, $location) {
var send = function(evt, data) {
ga('send', evt, data);
}
}
]);
app.directive( "carouselExampleItem", function($rootScope, $swipe){
return function(scope, element, attrs){
var startX = null;
var startY = null;
var endAction = "cancel";
var carouselId = element.parent().parent().attr("id");
var translateAndRotate = function(x, y, z, deg){
element[0].style["-webkit-transform"] = "translate3d("+x+"px,"+ y +"px," + z + "px) rotate("+ deg +"deg)";
element[0].style["-moz-transform"] = "translate3d("+x+"px," + y +"px," + z + "px) rotate("+ deg +"deg)";
element[0].style["-ms-transform"] = "translate3d("+x+"px," + y + "px," + z + "px) rotate("+ deg +"deg)";
element[0].style["-o-transform"] = "translate3d("+x+"px," + y + "px," + z + "px) rotate("+ deg +"deg)";
element[0].style["transform"] = "translate3d("+x+"px," + y + "px," + z + "px) rotate("+ deg +"deg)";
}
$swipe.bind(element, {
start: function(coords) {
endAction = null;
startX = coords.x;
startY = coords.y;
},
cancel: function(e) {
endAction = null;
translateAndRotate(0, 0, 0, 0);
e.stopPropagation();
},
end: function(coords, e) {
if (endAction == "prev") {
$rootScope.carouselPrev(carouselId);
} else if (endAction == "next") {
$rootScope.carouselNext(carouselId);
}
translateAndRotate(0, 0, 0, 0);
e.stopPropagation();
},
move: function(coords) {
if( startX != null) {
var deltaX = coords.x - startX;
var deltaXRatio = deltaX / element[0].clientWidth;
if (deltaXRatio > 0.3) {
endAction = "next";
} else if (deltaXRatio < -0.3){
endAction = "prev";
} else {
endAction = null;
}
translateAndRotate(deltaXRatio * 200, 0, 0, deltaXRatio * 15);
}
}
});
}
});
app.controller('MainController', function($rootScope, $scope, analytics){
$rootScope.$on("$routeChangeStart", function(){
$rootScope.loading = true;
});
$rootScope.$on("$routeChangeSuccess", function(){
$rootScope.loading = false;
});
var scrollItems = [];
for (var i=1; i<=100; i++) {
scrollItems.push("Item " + i);
}
$scope.scrollItems = scrollItems;
$scope.invoice = {payed: true};
$scope.userAgent = navigator.userAgent;
$scope.chatUsers = [
{ name: "Carlos Flowers", online: true },
{ name: "Byron Taylor", online: true },
{ name: "Jana Terry", online: true },
{ name: "Darryl Stone", online: true },
{ name: "Fannie Carlson", online: true },
{ name: "Holly Nguyen", online: true },
{ name: "Bill Chavez", online: true },
{ name: "Veronica Maxwell", online: true },
{ name: "Jessica Webster", online: true },
{ name: "Jackie Barton", online: true },
{ name: "Crystal Drake", online: false },
{ name: "Milton Dean", online: false },
{ name: "Joann Johnston", online: false },
{ name: "Cora Vaughn", online: false },
{ name: "Nina Briggs", online: false },
{ name: "Casey Turner", online: false },
{ name: "Jimmie Wilson", online: false },
{ name: "Nathaniel Steele", online: false },
{ name: "Aubrey Cole", online: false },
{ name: "Donnie Summers", online: false },
{ name: "Kate Myers", online: false },
{ name: "Priscilla Hawkins", online: false },
{ name: "Joe Barker", online: false },
{ name: "Lee Norman", online: false },
{ name: "Ebony Rice", online: false }
];
});