Fixed list item edit icon and options exposed issue for #76

Still needs work on the border issue @adamdbradley
This commit is contained in:
Max Lynch
2013-11-06 10:01:27 -06:00
parent b3445155aa
commit cc61fb5ff3
2 changed files with 28 additions and 6 deletions

View File

@ -3,7 +3,7 @@
angular.module('ionic.ui.list', ['ngAnimate'])
.directive('listItem', function() {
.directive('listItem', ['$timeout', function($timeout) {
return {
restrict: 'E',
require: ['?^list', '?^virtualList'],
@ -24,7 +24,7 @@ angular.module('ionic.ui.list', ['ngAnimate'])
</div>\
<div class="item-content slide-left" ng-transclude>\
</div>\
<div class="item-options" ng-if="canSwipe && !isEditing">\
<div class="item-options" ng-if="canSwipe && !isEditing && showOptions">\
<button ng-click="buttonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in buttons">{{button.text}}</button>\
</div>\
</a>',
@ -54,6 +54,7 @@ angular.module('ionic.ui.list', ['ngAnimate'])
$scope.isEditing = false;
$scope.deleteIcon = list.scope.deleteIcon;
$scope.reorderIcon = list.scope.reorderIcon;
$scope.showOptions = true;
$scope.buttonClicked = function(button) {
button.onButtonClicked && button.onButtonClicked($scope.item, button);
@ -61,10 +62,20 @@ angular.module('ionic.ui.list', ['ngAnimate'])
list.scope.$watch('isEditing', function(v) {
$scope.isEditing = v;
// Add a delay before we allow the options layer to show, to avoid any odd
// animation issues
if(!v) {
$timeout(function() {
$scope.showOptions = true;
}, 200);
} else {
$scope.showOptions = false;
}
});
}
};
})
}])
.directive('list', function() {
return {