Fixed dragging list items

This commit is contained in:
Max Lynch
2013-10-11 16:50:05 -05:00
parent 17ae340b13
commit 1839797a24
5 changed files with 23 additions and 4 deletions

View File

@ -247,14 +247,16 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
<div class="list-item-content" ng-transclude>\
</div>\
<div class="list-item-drag" ng-if="canReorder && isEditing">\
<button ng-click="startReorder()"><i ng-class="reorderIcon"></i></button>\
<button class="button button-icon" ng-click="startReorder()"><i ng-class="reorderIcon"></i></button>\
</div>\
<div class="list-item-buttons" ng-if="canSwipe && !isEditing">\
<button ng-click="onButtonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in buttons">{{button.text}}</button>\
</div>\
</li>',
link: function($scope, $element, $attr, list) {
$scope.isEditing = false;
$scope.deleteIcon = list.scope.deleteIcon;
$scope.reorderIcon = list.scope.reorderIcon;
list.scope.$watch('isEditing', function(v) {
$scope.isEditing = v;
@ -271,7 +273,8 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
scope: {
isEditing: '=',
deleteIcon: '@'
deleteIcon: '@',
reorderIcon: '@'
},
// So we can require being under this

5
dist/js/ionic.js vendored
View File

@ -1928,6 +1928,11 @@ window.ionic = {
_this._startDrag(e);
}
// We really aren't dragging
if(!_this._currentDrag) {
return;
}
// Check if we should start dragging. Check if we've dragged past the threshold,
// or we are starting from the open state.
if(!_this._isDragging &&

View File

@ -22,14 +22,16 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
<div class="list-item-content" ng-transclude>\
</div>\
<div class="list-item-drag" ng-if="canReorder && isEditing">\
<button ng-click="startReorder()"><i ng-class="reorderIcon"></i></button>\
<button class="button button-icon" ng-click="startReorder()"><i ng-class="reorderIcon"></i></button>\
</div>\
<div class="list-item-buttons" ng-if="canSwipe && !isEditing">\
<button ng-click="onButtonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in buttons">{{button.text}}</button>\
</div>\
</li>',
link: function($scope, $element, $attr, list) {
$scope.isEditing = false;
$scope.deleteIcon = list.scope.deleteIcon;
$scope.reorderIcon = list.scope.reorderIcon;
list.scope.$watch('isEditing', function(v) {
$scope.isEditing = v;
@ -46,7 +48,8 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
scope: {
isEditing: '=',
deleteIcon: '@'
deleteIcon: '@',
reorderIcon: '@'
},
// So we can require being under this

View File

@ -51,7 +51,10 @@
<content has-header="true" ng-controller="TestCtrl" class="reveal-animation">
<list is-editing="isEditingItems" animation="my-repeat-animation" delete-icon="icon-minus-circled" reorder-icon="icon-navicon">
<list-item ng-repeat="item in items"
buttons="item.buttons"
can-delete="true"
can-reorder="true"
can-swipe="true"
on-delete="deleteProject(project)"
on-select="selectProject(project)">
{{item.text}}

View File

@ -122,6 +122,11 @@
_this._startDrag(e);
}
// We really aren't dragging
if(!_this._currentDrag) {
return;
}
// Check if we should start dragging. Check if we've dragged past the threshold,
// or we are starting from the open state.
if(!_this._isDragging &&