如何在jQuery中关注滚动条时禁用可拖动div [英] how to disable draggable div when scroll bar is focused on in jQuery
问题描述
我有一个带有侧滚动条的jQuery可拖动容器div,当我滚动上下时不应该拖动。 .infotext是具有文本的内部div,包含在设置为溢出的#infobody中:auto。当滚动条被选中时,我需要一种方法来否定div上的可拖动函数。这里是我的代码:
I have a jQuery draggable container div with a side scroll bar that should not be draggable when I am scrolling up and down. .infotext is the inner div that has the text, contained within #infobody which is set to overflow:auto. I need a way to negate the draggable function on the div when the scrollbar is selected. Here is my code:
$(".lsidebar").draggable({"scroll":false});
.lsidebar #infobody{
cursor:default;
position:absolute;
width:100%;
overflow:auto;
margin:23px 0 0 0;
z-index:14;
}
#infobody .infotext{
cursor:default;
position:relative;
width:100%;
z-index:14;
color:#969696;
}
推荐答案
解决此问题的方法因为最近没有人回答我的问题)是用一个名为jScrollPane的jQuery滚动条代替默认的浏览器滚动条。这样做可以让我使用插入的滚动条ID作为选择器来禁用可拖动的...如此:
A workaround to this problem (because for some reason no one is answering my questions as of recently) was to substitute the default browser scrollbar with a jQuery scrollbar known as jScrollPane. Doing this allows me to use the inserted scrollbar ID as a selector to disable draggable...like so:
$('.jScrollPaneDrag').live('mousedown mouseup', function(e){
if(e.type=='mousedown'){
$('.lsidebar').draggable({disable: true});
}else{
$('.lsidebar').draggable({"scroll":false});
};
});
这篇关于如何在jQuery中关注滚动条时禁用可拖动div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!