English 中文(简体)
如何检查元素是否正在拖动
原标题:How to check if element is currently dragging

我希望能够检查一个事件在调用函数时是否正在发生。 当使用. 拖动 () 向上或向下拖动我的自定义滚动条时, 我有一个函数被调用, 当容器滚动时, 我也有函数被调用。 问题在于两者同时运行, 使它发生错误 。

所以,我的问题是,我该如何做一个“如果”的语句, 检查卷轴条是否被拖动, 这样我才能阻止它执行函数代码的其余部分?

我不是在问一个元素是否“附着”于它,而是问该元素是否是在某个时刻触发的。

我能做到吗 或者我需要换个方法吗

我的代码是这样的:

$( .container ).scroll(function(){
    //get the heights of the container and it s contents and the difference
    //get the height of the scroll bar and it s container and the difference
    //declare the top property of scroll bar from this info
});
function scrolly() {
    //get the heights of the elements described above
    //declare the scrollTop of the container
}
$( .bar ).draggable({
    axis:  y ,
    containment:  parent ,    
    drag: function() {
        scrolly();
    }
});
最佳回答

<强 > 更新

您可以使用此条件查找您的酒吧是否被拖动 :

if ($( .bar ).is( .ui-draggable-dragging )) {
    return; // bar is being dragged
}
问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签