-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathangular-ui-router.html
153 lines (143 loc) · 5.23 KB
/
angular-ui-router.html
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
<!DOCTYPE html>
<html lang="en" ng-app="route">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="me-pageloading.min.css">
<style>
*{
margin: 0;
padding: 0;
}
html, body{
background: #4fc3f7;
width: 100%;
height: 100%;
text-align: center;
}
h1{
font-size: 30px;
color: #fff;
text-align: center;
padding-top: 50px;
}
div.demo{
width: 100%;
position: fixed;
left: 50%;
top: 30%;
color: #fff;
font-size: 24px;
line-height: 2;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
a.demo{
cursor: pointer;
text-align: center;
color: #fff;
font-weight: bold;
text-decoration: none;
font-size: 24px;
border-bottom: 2px solid #fff;
margin: 5px;
}
</style>
</head>
<body ng-controller="mainCtrl">
<h1>me-pageloading</h1>
<div ui-view></div>
<div class="demo">
点击
<br />
<a class="demo" ng-click="toggle()">此处</a>
<br />预览随机效果
<br />
<br />
预览特定效果
<br />
<select name="opt" id="opt" ng-model="effect" ng-change="show()">
<option value="random" selected>Random</option>
<option value="Lazy Stretch">Lazy Stretch</option>
<option value="Circle">Circle</option>
<option value="Spill">Spill</option>
<option value="Frame it">Frame it</option>
<option value="Tunnel vision">Tunnel vision</option>
<option value="Windscreen wiper">Windscreen wiper</option>
<option value="Jammed blind">Jammed blind</option>
<option value="Parallelogram">Parallelogram</option>
<option value="Tilted">Tilted</option>
<option value="Lateral Swipe">Lateral Swipe</option>
<option value="Wave">Wave</option>
<option value="Origami">Origami</option>
<option value="Curtain">Curtain</option>
</select>
</div>
<a href="https://github.com/jeremial/me-pageloading"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<script src="http://cdn.staticfile.org/snap.svg/0.2.0/snap.svg-min.js"></script>
<script src="http://cdn.staticfile.org/angular.js/1.2.18/angular.min.js"></script>
<script src="http://cdn.staticfile.org/angular-ui-router/0.2.10/angular-ui-router.min.js"></script>
<script src="me-pageloading.min.js"></script>
<script>
angular.module('route', [
'ui.router',
'me-pageloading'
])
.config(['$stateProvider', '$urlRouterProvider', 'mePageLoadingProvider', function($stateProvider, $urlRouterProvider, mePageLoadingProvider){
$stateProvider
.state('page1', {
url: '/page1',
template: '<div></div>',
controller: 'page1',
resolve: {
data: ['$q', function($q){
var defer = $q.defer();
setTimeout(function(){
defer.resolve('page1');
}, 1500);
return defer.promise;
}]
}
})
.state('page2', {
url: '/page2',
template: '<div></div>',
controller: 'page2',
resolve: {
data: ['$q', function($q){
var defer = $q.defer();
setTimeout(function(){
defer.resolve('page2');
}, 1500);
return defer.promise;
}]
}
});
$urlRouterProvider.otherwise('/page1');
}])
.controller('page1', ['data', function(data){
}])
.controller('page2', ['data', function(data){
}])
.controller('mainCtrl', ['$scope', '$location', 'mePageLoading', function($scope, $location, mePageLoading){
$scope.effect = 'random';
$scope.show = function(){
// 手动调用动画
mePageLoading.show($scope.effect);
setTimeout(function(){
mePageLoading.hide();
}, 1500);
};
$scope.toggle = function(){
// 自动调用动画
if($location.path() === '/page1'){
$location.path('/page2');
}else{
$location.path('/page1');
}
};
}])
;
</script>
</body>
</html>