Javascript 使用ng sortable禁用页面滚动

Javascript 使用ng sortable禁用页面滚动,javascript,angularjs,ng-sortable,Javascript,Angularjs,Ng Sortable,我正在创建一个可排序列表和一个角度库。我遇到的问题是,在移动设备上,这种行为是不一致的。在android(chrome)上触摸和移动列表时,页面不会滚动(这是所需的行为),但在ipad(chrome)上会滚动 我在中创建了一个简单的示例,其中包含一个基本示例 JAVASCRIPT: var myApp = angular.module('myApp',['ui.sortable']); myApp.controller('MyCtrl', function($scope) { $sco

我正在创建一个可排序列表和一个角度库。我遇到的问题是,在移动设备上,这种行为是不一致的。在android(chrome)上触摸和移动列表时,页面不会滚动(这是所需的行为),但在ipad(chrome)上会滚动

我在中创建了一个简单的示例,其中包含一个基本示例

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:


ng可排序站点上也记录了相同的问题


还有一个longTouch/longTouchActive(旧版本用户更好地使用ngTable对表格进行排序,我认为它更容易,我对它进行了测试,并且工作正常,您可以按照下面的完整示例进行操作:

这是代码中添加表排序的部分

function demoController(NgTableParams, simpleList) {
this.tableParams = new NgTableParams({
  // initial sort order
  sorting: { name: "asc" } 
}, {
  dataset: simpleList
});
}

但是不要使用simpleList,只需遵循没有它的示例,将数据放在simpleList中,然后复制html,看看它是如何工作的,并添加自定义attrs,我希望我已经帮到了你,如果你还有其他问题,你可以回复此评论:p

.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;
}
function demoController(NgTableParams, simpleList) {
this.tableParams = new NgTableParams({
  // initial sort order
  sorting: { name: "asc" } 
}, {
  dataset: simpleList
});