Jquery-ui draggable: how to make a draggable element scroll a div when hovering over it

时间秒杀一切 提交于 2019-12-11 02:56:39

问题


I've got a bunch of draggable elements, and the droppable elements that receive them are in a div that is set to overflow-y: scroll.

The 'scroll' option of draggable works to scroll the whole page, but I cannot get it to scroll the parent div of the droppables. I've tried changing the containment attribute of the draggable to be the droppables' parent on hover, but that doesn't work either.

If anyone knows of a way to do this, I'd greatly appreciate it. Here's the basic idea of what I'm trying to do: http://jsfiddle.net/4gMVf/5/


回答1:


I forked your fiddle, and folded in this nifty solution.

Check it out: http://jsfiddle.net/crowjonah/Fr7u8/2/ There are a couple anchor areas that, when dragged over, will autoscroll the droppable.

I, like him, gave the anchors some visibility so you can see how they're working. You'll most likely want them totally transparent for end use.

I can't be sure, but it seems like you've got some other issues with your droppable, though, as it doesn't seem to be accepting your draggables, but since that wasn't your question, I won't try and solve that problem.



来源:https://stackoverflow.com/questions/12376001/jquery-ui-draggable-how-to-make-a-draggable-element-scroll-a-div-when-hovering

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