mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
List demo with animations!
This commit is contained in:
18
dist/ionic-angular.js
vendored
18
dist/ionic-angular.js
vendored
@ -180,24 +180,27 @@ angular.module('ionic.ui.content', [])
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
angular.module('ionic.ui.list', ['ionic.service'])
|
angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
|
||||||
|
|
||||||
.directive('listItem', function() {
|
.directive('listItem', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
replace: true,
|
||||||
transclude: true,
|
transclude: true,
|
||||||
template: '<li class="list-item">' +
|
template: '<li class="list-item">' +
|
||||||
' <div class="list-item-edit" ng-if="item.canDelete">' +
|
' <div class="list-item-edit" ng-if="item.canDelete">' +
|
||||||
' <button class="button button-icon"><i class="icon-minus-sign"></i></button>' +
|
' <button class="button button-icon"><i class="icon-minus-sign"></i></button>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' <div class="list-item-content" ng-transclude>' +
|
' <div class="list-item-content" ng-transclude>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' <div class="list-item-buttons" ng-if="item.canSwipe">' +
|
' <div class="list-item-buttons" ng-if="item.canSwipe">' +
|
||||||
' <button class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
' <button ng-click="buttonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
'</li>',
|
'</li>',
|
||||||
link: function($scope, $element, $attr) {
|
link: function($scope, $element, $attr) {
|
||||||
|
$scope.buttonClicked = function(button) {
|
||||||
|
button.buttonClicked && button.buttonClicked($scope.item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -209,10 +212,11 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
transclude: true,
|
transclude: true,
|
||||||
scope: {
|
scope: {
|
||||||
isEditing: '=',
|
isEditing: '=',
|
||||||
items: '='
|
items: '=',
|
||||||
|
animation: '='
|
||||||
},
|
},
|
||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
||||||
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
'<list-item ng-repeat="item in items | filter:{hide:\'false\'}" canDelete="item.canDelete" canSwipe="item.canSwipe" animation="my-repeat-animation">' +
|
||||||
' {{item.text}}' +
|
' {{item.text}}' +
|
||||||
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
||||||
'</list-item>' +
|
'</list-item>' +
|
||||||
@ -221,6 +225,10 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
return function($scope, $element, $attr) {
|
return function($scope, $element, $attr) {
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
var lv = new ionic.views.List({el: $element[0]});
|
||||||
|
|
||||||
|
if(attr.animation) {
|
||||||
|
$element.addClass(attr.animation);
|
||||||
|
}
|
||||||
|
|
||||||
$element.append(transclude($scope));
|
$element.append(transclude($scope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
dist/ionic-ios7.css
vendored
2
dist/ionic-ios7.css
vendored
@ -1073,7 +1073,7 @@ a.list-item {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
-webkit-transition: left 0.2s ease-in-out; }
|
-webkit-transition: left 0.2s ease-in-out, right 0.2s ease-in-out; }
|
||||||
.list-item-content > i:last-child {
|
.list-item-content > i:last-child {
|
||||||
float: right; }
|
float: right; }
|
||||||
|
|
||||||
|
|||||||
2
dist/ionic.css
vendored
2
dist/ionic.css
vendored
@ -1161,7 +1161,7 @@ a.list-item {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
-webkit-transition: left 0.2s ease-in-out; }
|
-webkit-transition: left 0.2s ease-in-out, right 0.2s ease-in-out; }
|
||||||
.list-item-content > i:last-child {
|
.list-item-content > i:last-child {
|
||||||
float: right; }
|
float: right; }
|
||||||
|
|
||||||
|
|||||||
18
js/ext/angular/src/directive/ionicList.js
vendored
18
js/ext/angular/src/directive/ionicList.js
vendored
@ -1,21 +1,24 @@
|
|||||||
angular.module('ionic.ui.list', ['ionic.service'])
|
angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
|
||||||
|
|
||||||
.directive('listItem', function() {
|
.directive('listItem', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
replace: true,
|
||||||
transclude: true,
|
transclude: true,
|
||||||
template: '<li class="list-item">' +
|
template: '<li class="list-item">' +
|
||||||
' <div class="list-item-edit" ng-if="item.canDelete">' +
|
' <div class="list-item-edit" ng-if="item.canDelete">' +
|
||||||
' <button class="button button-icon"><i class="icon-minus-sign"></i></button>' +
|
' <button class="button button-icon"><i class="icon-minus-sign"></i></button>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' <div class="list-item-content" ng-transclude>' +
|
' <div class="list-item-content" ng-transclude>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
' <div class="list-item-buttons" ng-if="item.canSwipe">' +
|
' <div class="list-item-buttons" ng-if="item.canSwipe">' +
|
||||||
' <button class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
' <button ng-click="buttonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
||||||
' </div>' +
|
' </div>' +
|
||||||
'</li>',
|
'</li>',
|
||||||
link: function($scope, $element, $attr) {
|
link: function($scope, $element, $attr) {
|
||||||
|
$scope.buttonClicked = function(button) {
|
||||||
|
button.buttonClicked && button.buttonClicked($scope.item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -27,10 +30,11 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
transclude: true,
|
transclude: true,
|
||||||
scope: {
|
scope: {
|
||||||
isEditing: '=',
|
isEditing: '=',
|
||||||
items: '='
|
items: '=',
|
||||||
|
animation: '='
|
||||||
},
|
},
|
||||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
||||||
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
'<list-item ng-repeat="item in items | filter:{hide:\'false\'}" canDelete="item.canDelete" canSwipe="item.canSwipe" animation="my-repeat-animation">' +
|
||||||
' {{item.text}}' +
|
' {{item.text}}' +
|
||||||
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
||||||
'</list-item>' +
|
'</list-item>' +
|
||||||
@ -39,6 +43,10 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
|||||||
return function($scope, $element, $attr) {
|
return function($scope, $element, $attr) {
|
||||||
var lv = new ionic.views.List({el: $element[0]});
|
var lv = new ionic.views.List({el: $element[0]});
|
||||||
|
|
||||||
|
if(attr.animation) {
|
||||||
|
$element.addClass(attr.animation);
|
||||||
|
}
|
||||||
|
|
||||||
$element.append(transclude($scope));
|
$element.append(transclude($scope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,30 +11,39 @@
|
|||||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-touch.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-touch.js"></script>
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.js"></script>
|
||||||
<style>
|
<style>
|
||||||
.reveal-animation {
|
.my-repeat-animation > .ng-enter,
|
||||||
/*
|
.my-repeat-animation > .ng-leave,
|
||||||
-webkit-transform: translate3d(0%, 0, 0);
|
.my-repeat-animation > .ng-move {
|
||||||
transform: translate3d(0%, 0, 0);
|
-webkit-transition: 0.2s linear all;
|
||||||
|
transition: 0.2s linear all;
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-repeat-animation > .ng-enter {
|
||||||
|
left:-10px;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
.my-repeat-animation > .ng-enter.ng-enter-active {
|
||||||
|
left:0;
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-repeat-animation > .ng-leave {
|
||||||
|
left:0;
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
.my-repeat-animation > .ng-leave.ng-leave-active {
|
||||||
|
left:-10px;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-repeat-animation > .ng-move {
|
||||||
|
opacity:0.5;
|
||||||
|
}
|
||||||
|
.my-repeat-animation > .ng-move.ng-move-active {
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
|
||||||
-webkit-transition: -webkit-transform 1s ease-in-out;
|
|
||||||
transition: transform 1s ease-in-out;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
.reveal-animation.ng-enter {
|
|
||||||
-webkit-transition: .2s ease-in-out all;
|
|
||||||
-webkit-transform:translate3d(100%,0,0) ;
|
|
||||||
}
|
|
||||||
.reveal-animation.ng-enter-active {
|
|
||||||
-webkit-transform:translate3d(0,0,0) ;
|
|
||||||
}
|
|
||||||
.reveal-animation.ng-leave {
|
|
||||||
-webkit-transition: .2s ease-in-out all;
|
|
||||||
-webkit-transform:translate3d(0%,0,0);
|
|
||||||
}
|
|
||||||
.reveal-animation.ng-leave-active {
|
|
||||||
-webkit-transition: .2s ease-in-out all;
|
|
||||||
-webkit-transform:translate3d(-100%,0,0);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -73,7 +82,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</list>
|
</list>
|
||||||
<list items="items" is-editing="isEditingItems">
|
<list items="items" is-editing="isEditingItems" animation="my-repeat-animation">
|
||||||
</list>
|
</list>
|
||||||
<button ng-click="edit()" class="button button-success">Edit</button>
|
<button ng-click="edit()" class="button button-success">Edit</button>
|
||||||
</content>
|
</content>
|
||||||
@ -81,7 +90,7 @@
|
|||||||
<script src="../../../../dist/ionic.js"></script>
|
<script src="../../../../dist/ionic.js"></script>
|
||||||
<script src="../../../../dist/ionic-angular.js"></script>
|
<script src="../../../../dist/ionic-angular.js"></script>
|
||||||
<script>
|
<script>
|
||||||
angular.module('navTest', ['ionic.ui.list'])
|
angular.module('navTest', ['ionic.ui.list', 'ngAnimate'])
|
||||||
|
|
||||||
.controller('TestCtrl', function($scope) {
|
.controller('TestCtrl', function($scope) {
|
||||||
$scope.items = [
|
$scope.items = [
|
||||||
@ -90,9 +99,15 @@
|
|||||||
canDelete: true,
|
canDelete: true,
|
||||||
canSwipe: true,
|
canSwipe: true,
|
||||||
icon: 'icon-chevron-right',
|
icon: 'icon-chevron-right',
|
||||||
|
hide: false,
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: 'Kill',
|
text: 'Kill',
|
||||||
type: 'button-danger'
|
type: 'button-danger',
|
||||||
|
buttonClicked: function(item) {
|
||||||
|
// Remove ourselves
|
||||||
|
//$scope.items.splice($scope.items.indexOf(item), 1);
|
||||||
|
item.hide = true;
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -107,7 +107,7 @@ a.list-item {
|
|||||||
|
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
|
|
||||||
-webkit-transition: left 0.2s ease-in-out;
|
-webkit-transition: left 0.2s ease-in-out, right 0.2s ease-in-out;
|
||||||
|
|
||||||
// Align icons to the right
|
// Align icons to the right
|
||||||
> i:last-child {
|
> i:last-child {
|
||||||
|
|||||||
Reference in New Issue
Block a user