jquery 可拖动/可放置
任何有关以下内容的帮助将不胜感激。我需要在可放置的盒子外面放一张图片。用户应该能够将图片拖动到框中,并且一旦图片位于框内,用户应该仍然能够拖动它,但只能拖动到框内。
预先感谢您的任何指点。
Any help with the following will be much appreciated. I need to have a picture outside a droppable box. The user should be able to drag the picture to the box and once the picture is inside the box, the user should still be able to drag it, but only inside of the box.
Thank you in advance for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以通过在可放置对象的“drop”回调中向可拖动对象添加“containment”选项来完成。例如:
在上面的选项中,一旦项目实际被放置,放置回调就会触发并导致可拖动项目被限制为“containment”选项中的项目。
This can be done by adding the "containment" option to the draggable object in the droppable object's "drop" callback. For example:
In the option above, once the item is actually dropped, the drop callback fires and causes the draggable item to be constrained to the item in the "containment" option.