Can jQuery ui Sortable behave like gridster?

和自甴很熟 提交于 2019-12-12 15:13:52

问题


Is it possible to get jQuery ui Sortable grid to behave like gridster?

Why not use gridster? Because it doesn't work on anything less than IE9.

Looking at the jQuery ui Sortable sample, if you drag number 5 to number 1, number 1 moves to the right. When I do the same action with gridster, number 1 would move to number 5's position. It continues to work even with different sized elements.

Is it possible to get jQuery ui Sotables grid to work in a similar manner?


回答1:


Hardly. All jQuery's sortable does is change the order of elements inside the parent element. The "grid behavior" showed in that demo is just the browser's layout engine behaving normally (placing elements from left to right while they fit on parent's width, then top to bottom). gridster on the other hand simulates a grid that independs on its elements: even if you remove all tiles from one column, it still occupies space on screen. Elements on columns are ordered, but rows are added/removed as needed.

Replicating that behavior fully would be a lot of work. The closest I could get to the gridster demo's behavior is the connect lists example, which you can style like a grid (example) but having every element of the same size.




回答2:


If you know how to work with jQuery libraries, there is a jQuery plugin called Isotope which work in a similar way: http://isotope.metafizzy.co/demos/fluid-responsive.html

If you need to add dragging events you can extend the isotope widget following such instructions: http://jstarrdewar.com/blog/2011/10/28/extend-jquery-draggable-to-work-with-isotope



来源:https://stackoverflow.com/questions/13134487/can-jquery-ui-sortable-behave-like-gridster

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