我目前正在开发一个包含一些测试的AngularJS应用程序。在其中一些中,我有一个列表,用户必须通过拖放来正确排序。

我正在使用angular-ui-sortable来实现。在PC和笔记本电脑上,它可以完美运行。当用户使用移动设备时,问题就来了,然后它停止工作。

我可以想象它与手机上的垂直滚动冲突,还是我完全错了?还有没有人也遇到过这个问题并提出了解决方案?或者可能会指出正确的方向,我将非常感激。

HTML(如果需要,我的HTML)

<ul ui-sortable ng-model="sequence" class="list-group list-group-lg list-group-sp">
    <li ng-repeat="choice in choices" class="list-group-item" draggable="true">
        <h5>{{choice.name}}</h5>
    </li>
</ul>

最佳答案

根据文档以及在github存储库上打开的问题,您可以添加jquery-ui来解决此问题。您可以从项目自述文件中检查此pen以供参考。

这是在笔上使用的代码:

的HTML

 <div class="floatleft">
    <ul ui-sortable="sortableOptions" ng-model="list" class="list">
      <li ng-repeat="item in list" class="item">
        {{item.text}}
      </li>
    </ul>
  </div>


控制者

  $scope.sortableOptions = {
    update: function(e, ui) {
      var logEntry = tmpList.map(function(i){
        return i.value;
      }).join(', ');
      $scope.sortingLog.push('Update: ' + logEntry);
    },
    stop: function(e, ui) {
      // this callback has the changed model
      var logEntry = tmpList.map(function(i){
        return i.value;
      }).join(', ');
      $scope.sortingLog.push('Stop: ' + logEntry);
    }
  };

10-07 19:59
查看更多