用同位素重新布局项目,似乎无法维持结构
我一直在玩同位素 http://isotope.metafizzy.co/demos/relayout.html 并一直在尝试创建一个保持固定大小的父容器, 总是有 6 个较小的项目,并重新调整以适应第 7 个较大的项目。
这是我到目前为止在 jsfiddle 上得到的内容 http://jsfiddle.net/pedalpete/LGBg6/
我希望发生的是点击后在任何块上,任何一行中较小块的总数将为 3。
出于某种原因,无论是用户 .isotope('resize'),还是像我一样重新创建同位素,我最终会得到一个数字顶行大于 3,因此项目排序不均匀。
我原以为,诉诸之后,安排会有些静态。 有没有办法让同位素服从绑定盒的宽度和高度参数?
I've been playing about with isotope a bit
http://isotope.metafizzy.co/demos/relayout.html
and have been trying to create a parent container that remains a fixed size,
always having 6 smaller items, and reshuffling to fit the 7th larger item.
Here is what I have so far on jsfiddle
http://jsfiddle.net/pedalpete/LGBg6/
What I was hoping would happen is that after clicking on any block, the total number of smaller blocks in any one row would be 3.
For some reason, either user .isotope('resize'), or resorting and recreating the isotope as I'm doing, I end up with a number greater than 3 in the top row, so the items are not sorted evenly.
I would have thought that the arrangement would be somewhat static after resorting.
Is there a way to have isotope obey the width and height parameters of the binding box??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅 http://jsfiddle.net/desandro/S5vAG/ 了解我的解决方案。
第一步是禁用 Isotope 调整容器大小。设置 resizesContainer 选项
false
。现在,为了将这些块安装到容器中,有多种方法可以实现。您可以构建自己的布局模式,或者可以尝试进行排序。这是我采用的解决方案。
我还使用了不同的布局模式,
fitColumns
,我认为它更适合您的需求。使用getSortData
参数,其逻辑是,如果该项目具有large
类并且是偶数项目,则它将被推回下一列。因此,当 2、4、6 很大时,它们都会被放置在下一列中。See http://jsfiddle.net/desandro/S5vAG/ for my solution.
The first step is to disable Isotope resizing the container. Set the resizesContainer option
false
.Now to accomplish fitting those blocks into the container, there are several ways to do this. You could build your own layoutMode, or you could try playing around with sorting. This is the solution I employed.
I also used a different layoutMode,
fitColumns
, which I think better suits what you're going for. Using thegetSortData
parameter, the logic is that if the item has a class oflarge
AND is an even item, then it gets pushed back into the next column. So 2, 4, 6 all get placed in the next column when they are big.