【发布时间】:2014-11-12 14:44:20
【问题描述】:
我正在使用AngularJS 和一个角度库ng-sortable 创建一个可排序列表。我遇到的问题是在移动设备上的行为不一致。在 android (chrome) 上触摸和移动列表时页面不会滚动(这是所需的行为),但在 ipad (chrome) 上会滚动
我在jsFiddle 中创建了一个简单的示例,其中包含一个基本示例
JAVASCRIPT:
var myApp = angular.module('myApp',['ui.sortable']);
myApp.controller('MyCtrl', function($scope) {
$scope.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
$scope.sortableOptions = {
orderChanged: function (event) {
console.log("event", event);
}
};
});
HTML:
<div ng-controller="MyCtrl">
<ul as-sortable="sortableOptions" ng-model="items">
<li class="display-item" as-sortable-item ng-repeat="item in items">
<div class="handle" >
<div class="item-handle" as-sortable-item-handle>
{{item}}
</div>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</div>
</div>
</li>
</ul>
CSS:
.display-item {
clear: both;
}
.handle {
border: 1px solid #e5e5e5;
padding: 10px;
margin: 0px;
}
.item-handle {
background: grey;
float:left;
padding: 2px 5px;
}
/* ************************************** */
/* Mandatory CSS required for ng-sortable */
/* ************************************** */
.as-sortable-item, .as-sortable-placeholder {
display: block;
}
.as-sortable-placeholder {
background: pink;
}
.as-sortable-item {
-ms-touch-action: none;
touch-action: none;
}
.as-sortable-item-handle {
cursor: move;
}
.as-sortable-placeholder {
}
.as-sortable-drag {
position: absolute;
pointer-events: none;
z-index: 9999;
}
.as-sortable-hidden {
display: none !important;
}
【问题讨论】:
标签: javascript angularjs ng-sortable