如何在 android 设备上使 bootstrap 模态可拖动和可滚动

how to make bootstrap modal draggable and scrollable on android device

我遇到了 bootstrap 模式的问题,它应该是可拖动和可滚动的。在桌面上它工作正常,但在我的 android 设备上,它在可拖动时不再滚动。就像“冻结”一样。 当我禁用可拖动时,可滚动再次正常工作。

我正在使用 jQuery UI 使其可拖动:

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">

      some long content goes here
 
        </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script>
// make modal resizable and draggable
$('.modal-content').resizable({
  minHeight: 300,
  minWidth: 300
});
$('.modal-dialog').draggable(); // here seems to be the issue on android device; when disabled, scrollable but not draggable, when enabled, draggable but not scrollable on android
</script>

我创建了一个 fiddle,您可以在其中查看行为: FIDDLE

$('.modal-dialog').draggable({
    handle: ".modal-header"
});

这应该可以解决您的问题

Fiddle