jQuery UI's Draggable and page scrolling

ε祈祈猫儿з 提交于 2019-12-23 10:53:45

问题


I noticed when I use jQuery UI's draggable feature and I have to drag the element so far up/down the page that it forces a scroll. The element being dragged seems to jump (about) twice as fast as my mouse cursor. This causes very erratic behavior and makes it almost impossible to use.

An example of what I mean can be found here.

http://tinyurl.com/ae6g5qe

I even get this behavior on the sample code on the jQuery UI's site.

http://jqueryui.com/draggable/#scroll

I have a guess that it is using both the mouse movement AND the window scroll to increase the movement of the element (So twice as much). I'm about to delve into jQuery UI's code and see if I can find anything, but I'm curious if anyone else has experienced this or if it is just me? Also, if anyone has - have you gotten around it somehow?


回答1:


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.

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 (using jQuery 1.7.2 and jQuery UI 1.7.3)



来源:https://stackoverflow.com/questions/14820826/jquery-uis-draggable-and-page-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!