包含 jQueryUI 可拖动的自定义
我希望使用 jQueryUI 的可拖动小部件,但限制对象,使其绑定到浏览器窗口的顶部、左侧和右侧。
但是,我希望允许对象能够在窗口下方拖动,直到对象只有 30 个像素可见。那时我希望它不允许进一步向下拖动。因此,我希望对象的至少 30 像素始终可见,这样仍然可以轻松地将其拖回到视图中。
是否可以使用插件在约束上定义此类型?如果可以,如何完成?
I wish to to use jQueryUI's draggable widget, but constrain the object so that it is bound to the browser's window on the top, left, and right.
But, I want to allow the object to be able to drag below the window up until there's only 30 pixels of the object visible. At that point I'd like it to disallow dragging any further down. So, I want at least 30 pixels of the object to always be visible so it's still easy to drag back up into view.
Is it possible to define this type on a constraint using the plugin?, If so how is it done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可拖动小部件有一个可以使用的
containment
选项限制可拖动元素可以拖动的范围。该选项可以采用一组值,因此类似这样的东西应该可以解决问题:这是一个工作示例以上。我从
document.height
中减去了70
,因为示例中的可拖动元素的高度为100px
。The draggable widget has a
containment
option which can be used to constrain the limits in which the draggable element can be dragged. That option can take an array of values, so something like this should do the trick:Here's a working example of the above. I've subtracted
70
fromdocument.height
because the draggable element in the example is100px
tall.