jQuery draggable : the draggable box go over the container - bug?

匆匆过客 提交于 2019-12-12 10:43:07

问题


Try this code :

HTML

<div class="draggable_container">
    <div id="draggable_1" class="draggable">
        <div class="exp"><!-- --></div>
    </div>
</div>

CSS

html
{
    height:3000px;
}

.draggable_container
{
    height:300px;
    background-color:red;
    width:140px;
}

.draggable
{
    height:60px;
    width:130px;
    cursor:pointer;
    border:5px solid #000000;
    background-color:#ffffff;
}

jQuery

$(".draggable").draggable({
    axis: "y",
    containment: 'parent'
});

Now, if you click on the box "draggable" and you move the mouse up and down, it will move till the container height.

But, if you click with the mouse to this box, and you scroll the page (with the mouse wheel...or moving the cursor to the bottom, without release the mouse) the box go over the container. And this sucks.

Is it a common bug? How can I fix this trouble?


回答1:


I don't know if this is a bug, but I solve it by adding overflow:auto to the .draggable_container css class. See it here: http://jsfiddle.net/QhVNr/2/



来源:https://stackoverflow.com/questions/8656653/jquery-draggable-the-draggable-box-go-over-the-container-bug

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