jQuery Draggable drags off screen

我怕爱的太早我们不能终老 提交于 2019-12-07 02:03:04

问题


When the user grabs the titlebar of a window and drags to the right all the way, the page will start to scroll right. Is there anyway to prevent this?

To reproduce: https://jqueryui.com/draggable/ Drag the window to the right.

I have overflow: hidden on the html and body tags. Not sure what else to do here. I'd prefer not to use the containment option on the window because I want them to be able to slide off screen slightly.


回答1:


When you use jQuery UI Draggable, you have an option called Containment. In that, you can specify the parent, inside which it should be constrained. In your case, the parent should be the body.

As an alternative, you could use the scroll option:

$( "#outlook" ).draggable({ scroll: false });



回答2:


Try this: Lets say your main element is a div named 'myWindow';

document.getElementById('myWindow').scrolling = "no";


来源:https://stackoverflow.com/questions/15265427/jquery-draggable-drags-off-screen

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