我想使用 jquery Draggable/droppable 让用户选择一组对象(每个对象的角落都有一个复选框),然后将所有选定的对象作为一组拖动...
我无法弄清楚我该怎么办哈哈。
这是我认为将导致一个可用的解决方案,在每个可拖动对象上,使用 start() 事件并以某种方式抓取所有其他选定的对象并将它们添加到
我也在考虑的选择中,只是使拖动的对象看起来像出于性能原因,一组对象(它们是图像,所以可能是一堆照片)。 我认为如果您一次拖动几十个对象,使用可拖动功能可能会失败,这听起来是一个更好的主意吗?
I want to use jquery draggable/droppable to let the user select a group of objects (each one has a checkbox in the corner) and then drag all the selected objects as a group...
I can't figure out for the life of me how to do it haha.
Here is what I'm thinking will lead to a usable solution, on each draggable object, use the start() event and somehow grab all the other selected objects and add them to the selection
I was also considering just making the dragged object look like a group of objects (they're images, so a pile of photos maybe) for performance reasons. I think using the draggable functionality might fall over if you drag several dozen objects at once, does that sound like a better idea?
发布评论
评论(4)
我为此所做的是创建一个函数,您可以向该函数提供从属/主元素,该函数为主元素创建一个 bind() 函数(在这种情况下,我只允许从主元素拖动,您可以解决此问题我确信这一点),这使得从属设备使用标准 jQuery css 跟随它。
我想一旦我有了一个可行的例子我就会发布更多内容。 就目前情况而言,这对我有用。 缺少的是一种使用您想要组合在一起的元素调用重叠(从属,主控)的方法。 我正在以一种非常具体的方式来做这件事。 我相信你可以想出一个聪明的方法来做到这一点。
What I've done for this is created a function that you give the slave / master elements to, which creates a bind() function for the master (I'm only allowing a drag from the master in this case, you can work around this I'm sure), which makes the slave follow it around using standard jQuery css.
I guess I'll post more to this once I have a working example. As it stands this is working for me. What is missing is a way to call overlap(slave, master) with the elements you want to group together. I'm doing this in a really specific way. You can clever a way to do it, I'm sure.
您可以使用可拖动的
helper
选项来拖动项目组。例如,如果您的可拖动对象有复选框,您可以从辅助函数中返回所选项目,如下所示:
演示
我已经设置了一个演示,其中包含可拖动图像、复选框和稍微流畅的布局。 点击底部的“运行代码片段”查看结果:
You could use the draggable's
helper
option to drag groups of items.For example, if your draggables have checkboxes, you can return the selected items from the helper function like so:
Demo
I've setup a demo with draggable images with checkboxes and somewhat fluid layout. Click "Run Code Snippet" at the bottom to see the result:
表现理念:
制作一个看不见的“群体对象”。 选中项目时,使它们成为组对象的子对象,取消选择时,将它们设置回文档正文的子对象,或静态父对象或其他。 您必须平移对象的位置以确保它们不会跳来跳去,并且在添加/删除对象时将鼠标事件处理程序附加/分离到组的子对象。
当您在任何子对象上收到鼠标向下/向上事件时,您将移动的实际上是该组对象。
这应该会使整体变得更简单。
Performance Idea:
Make an invisible 'group object'. When the items are checked, make them children of the group object, when unselected, set them back as children of the document body, or static parent or whatever. You'll have to translate the objects' position to make sure they don't jump around, also attach/detach your mouse event handlers to the children of the group as you add/remove them.
When you get a mouse down/up event on any of the children, what you'll move is actually that group object.
This should make it simpler overall.
这正是我正在尝试做的事情。 到目前为止我还没有成功,但我发现 这家伙以一种非常复杂的方式做到了这一点。 你可以检查一下,也许你可以用它做点什么。
这应该是draggable中的一个功能。 我希望他们尽快实施
This the exact thing I'm trying to do. So far I've not been successful, but I've found this guy done it in a very complicated way. you could check it out maybe you could do somthing with that.
This should be a feature in draggable. I hope they implement it sooner than later