Using jQuery UI Draggable, how to avoid drag when using scrollbar?

∥☆過路亽.° 提交于 2019-12-18 03:58:12

问题


A long time ago I created a dialog box in my application. The dialog is pretty simple, position absolute, centered in the screen via javascript.

Now I have added jQuery UI to the application but I do not want to use jQuery UI's dialogs just because they work differently. But I did make my dialog draggable using jQuery UI as it is very easy:

$('#dialog').draggable();

There is one problem with that, some of my dialogs have scrollbars.
But using the draggable method, if there is a scrollbar, it bugs because it drags the dialog.

Is there a way for the dialog to not drag while using the scrollbar ?
I noticed there are some ways to avoid elements to be dragged, but scrollbars are not elements.

Thank you

EDIT: JSFiddle: http://jsfiddle.net/FGXnR/


回答1:


As a workaround, you could try using the handle option and only make the dialog draggable by the parts that aren't scrollable. (The title or some such.)

jsFiddle Example

Another solution that @AlexFigueiredo pointed out involves just wrapping the content / handle in a div that handles the sizing and scrolling – that seems stop the click event from being sent to the handle.



来源:https://stackoverflow.com/questions/8793236/using-jquery-ui-draggable-how-to-avoid-drag-when-using-scrollbar

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