forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.html
More file actions
179 lines (160 loc) · 5.62 KB
/
content.html
File metadata and controls
179 lines (160 loc) · 5.62 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html ng-app="navTest">
<head>
<meta charset="utf-8">
<title>Content</title>
<!-- Sets initial viewport load and disables zooming -->
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
<script src="../../../../dist/js/ionic.bundle.js"></script>
</head>
<body ng-controller="ThisCtrl">
<ion-pane>
<ion-header-bar id="header" class="bar-positive">
<h1 class="title">Title</h1>
</ion-header-bar>
<ion-content id="container"
start-y="55"
class="has-tabs has-header" delegate-handle="myScroll">
<ion-refresher></ion-refresher>
<div id="search-box" class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios7-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
<button ng-click="doIt()" class="button button-assertive">Do et</button>
<div class="list">
<ion-input class="item item-input">
<input type="text" placeholder="First Name">
</ion-input>
<ion-input class="item item-input">
<input type="text" placeholder="Last Name">
</ion-input>
<ion-input class="item item-input">
<textarea placeholder="Comments"></textarea>
</ion-input>
<ion-input class="item item-input">
<ion-label>Username</ion-label>
<input type="text">
</ion-input>
</div>
<div ng-controller="TestCtrl"></div>
<button ng-click="add()">Click</button>
<ul class="list" ng-controller="AppCtrl">
<li class="list-item" ng-repeat="item in items">asdf{{$index}}</li>
</ul>
<input type="text" placeholder="INPUT TEXT">
</ion-content>
<nav id="tab-bar" class="tabs tabs-icon-top">
<a class="tab-item" href="#">
<i class="icon ion-game-controller-a"></i>
Fun
</a>
<a class="tab-item">
<i class="icon ion-locked"></i>
Security
</a>
<a class="tab-item">
<i class="icon ion-heart"></i>
Simple
</a>
<a class="tab-item">
<i class="icon ion-leaf"></i>
Light
</a>
<a class="tab-item">
<i class="icon ion-waterdrop"></i>
Clean
</a>
</nav>
</ion-pane>
<script>
angular.module('navTest', ['ionic'])
.directive('headerShrink', function($document) {
var fadeAmt;
var shrink = function(header, amt, max) {
//console.log('Translating up', amt);
amt = Math.min(max - 20, amt);
fadeAmt = 1 - amt / (max - 20);
ionic.requestAnimationFrame(function() {
header.style[ionic.CSS.TRANSFORM] = 'translate3d(0, -' + amt + 'px, 0)';
for(var i = 0, j = header.children.length; i < j; i++) {
header.children[i].style.opacity = fadeAmt;
}
});
};
return {
restrict: 'A',
link: function($scope, $element, $attr) {
var starty = $scope.$eval($attr.headerShrink) || 0;
var shrinkAmt;
var header = $document[0].body.querySelector('.bar-header');
var headerHeight = header.offsetHeight;
$element.bind('scroll', function(e) {
if(e.detail && e.detail.scrollTop > starty) {
// Start shrinking
shrinkAmt = headerHeight - Math.max(0, (starty + headerHeight) - e.detail.scrollTop);
shrink(header, shrinkAmt, headerHeight);
} else {
shrink(header, 0, headerHeight);
}
});
}
}
})
.directive('hidesHeader', function() {
return {
link: function($scope, $element, $attr) {
var startTop = $element[0].offsetTop;
}
}
})
.controller('TestCtrl', function($scope, $timeout) {
console.log('CONSTRUCT', ionic.Platform.isIOS());
$timeout(function() {
});
})
.controller('ThisCtrl', function($scope, $timeout, $ionicScrollDelegate) {
var header = document.getElementById('header');
var content = document.getElementById('container');
var startTop = header.offsetTop;
$scope.doIt = function() {
$ionicScrollDelegate.$getByHandle('myScroll').scrollTo(0, 400, true);
};
$scope.onScrollComplete = function(event, scrollTop, scrollLeft) {
}
$scope.add = function() {
console.log('Adding!');
};
var last = 0;
$scope.onRefresh = function() {
$timeout(function() {
$scope.$broadcast('scroll.refreshComplete');
}, 1000);
};
$scope.onScroll = function(event, scrollTop, scrollLeft) {
//console.log('Scroll', scrollTop, scrollLeft);
/*
if(scrollTop > startTop) {
var diff = scrollTop - startTop;
console.log(diff);
header.style[ionic.CSS.TRANSFORM] = 'translate3d(0px, -' + diff + 'px, 0)';
content.style.marginTop = -diff + 'px';
}
*/
};
})
.controller('AppCtrl', function($scope, $compile, $timeout, $element) {
$scope.items = [];
for(var i = 0; i < 70; i++) {
$scope.items.push({
});
}
})
</script>
</body>
</html>