Rearrange tiles within an area

笑着哭i 提交于 2019-12-23 16:16:59

问题


I'm trying to create a tile grid that can be rearranged. The tiles are of different sizes. Here's how far I've gotten.

http://jsfiddle.net/psivadasan/dMtRs/

How do I prevent tiles from being rearranged outside the grey area? I don't want this to happen: http://i.imgur.com/0JAfY.png

Appreciate any help.


回答1:


Just use the containment option: This will stop the elements being dragged outside.

$('ul').sortable( "option", "containment", 'parent' );

http://jsfiddle.net/dazefs/dMtRs/7/



来源:https://stackoverflow.com/questions/10745140/rearrange-tiles-within-an-area

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