且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery UI的可拖动和页面滚动

更新时间:2022-01-23 10:21:48

这似乎是一个打开错误。你可以看到,如果你使用1.7版本的jQuery UI,行为明显更好。

This appears to be an open bug in jQuery UI 1.8+. You can see that if you use version 1.7 of jQuery UI the behavior is noticeably better.

基于jQuery UI可拖动演示的示例:

Example based on jQuery UI's draggable demo:

HTML

<div id="draggable" class="ui-widget-content">
    <p>Scroll set to true, default settings</p>
</div>
<div style="height: 5000px; width: 1px;"></div>

JS

$(function () {
    $("#draggable").draggable({
        scroll: true
    });
});

jsfiddle (使用jQuery 1.7.2和jQuery UI 1.7.3)

jsfiddle (using jQuery 1.7.2 and jQuery UI 1.7.3)