如何禁用页面滚动,同时拖动jQuery中的可拖动? [英] How to disable page scroll while dragging draggable in jquery?

查看:95
本文介绍了如何禁用页面滚动,同时拖动jQuery中的可拖动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可拖动的方式定义:

I have a draggable defined this way:

$("#drag_area a").live("mouseup", function() {

    var object = $(this);
    var class_array = $(this).attr("class").split(" ");
    element(object,class_array);
    return false;

}).draggable({
    containment: "#drag_area",
    grid: [44, 44],
    zIndex: 1000
}).each(function(i, item){    
});

当我拖动类型为'drag_area a'的项目时,如果在拖动页面的同时滚动页面,物品退出遏制......这不是一个渴望的情况,所以我该如何避免这种情况?我可以在拖动过程中禁用页面滚动吗?

When i drag an item of the type 'drag_area a', if i scroll the page while dragging it, the item exits from containment... It is not a desidered situation, so how can i avoid this? Can i disable page scrolling during dragging?

推荐答案

您将使用所有可拖动的元素, em>,即为什么当拖放元素时,整个页面会因拖动而滚动。

You'll be using all your draggable elements without any container, i.e. why when you Drag-n-Drop your elements the whole page scrolls due to dragging.

而不是:

<div class="dragWrapper">
   <!-- Place all your draggable elements here -->
</div>

设置 max-height 和<$ dragWrapper 类的c $ c> overflow :

set a max-height and overflow of the dragWrapper class as:

.dragWrapper {
   max-height: 400px;
   overflow: auto;
}

现在,当您拖放元素,而不是你的 body ,滚动只会在容器内。

Now when you Drag-n-Drop your elements, instead of your body, scroll will be inside the container only.

希望这会为你带来诀窍。 )。

Hope that will do the trick for you(which already did ;).

这篇关于如何禁用页面滚动,同时拖动jQuery中的可拖动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆