0

我遇到了应该是可拖动和可滚动的引导模式的问题。在桌面上它工作正常,但在我的 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

4

1 回答 1

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

这应该可以解决您的问题

小提琴

于 2020-11-10T13:18:19.440 回答