如何在Android设备上使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

解决方法

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

这应该可以解决您的问题

Fiddle