JQuery drag/scrolling/overflow issue

眉间皱痕 提交于 2019-12-08 05:15:48

问题


I have a scrolling:auto problem with JQuery 1.4.2 and JQuery 1.7.2. I have a container DIV with 2 DIVs inside it. Like this:

<div id="dragContain">

<div id="dragMe">
  <div>Title goes here!</div>
  <div style="scrolling:auto;">Content goes here!</div>
</div>

</div>

And I enable dragging the group by:

$('#dragMe').draggable({
  containment: '#dragContain', cursor: 'move', zIndex: 20000
});

And, when I do so, in FF the scrolling only works with the mouse wheel. Grabbing the scrollbar causes a drag event and moves the group. It works fine in IE.

Is there any way to correct this? Can I make only the titlebar a grab handle which causes a drag on the parent div?

Thanks!


回答1:


You could try using a handle instead. So the user would drag and drop the h2 element instead of the whole of #dragMe.

$('#dragMe').draggable({
  containment: '#dragContain', cursor: 'move', zIndex: 20000, handle: 'h2'
});

.

<div id="dragContain">

<div id="dragMe">
  <h2>Title goes here!</h2>
  <div style="scrolling:auto;">Content goes here!</div>
</div>

</div>



回答2:


Or use CANCEL on the selector with the scrollbars to prevent the dragging from occurring on that object.

Example: http://jqueryui.com/demos/draggable/handle.html



来源:https://stackoverflow.com/questions/2307161/jquery-drag-scrolling-overflow-issue

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