简体   繁体   English

石工jQuery插件和空白

[英]Masonry jQuery plugin and empty spaces

I am thinking of using Masonry plugin in one of my projects. 我正在考虑在我的一个项目中使用Masonry插件 What I wonder about if it's possible some way to detect empty spaces that sometimes appear in the layout when divs are positioned. 我想知道是否有某种方法可以检测到在放置div时有时出现在布局中的空白区域。 If I had a way to check such blank spaces, I could fill them with some generated divs with some data in them. 如果我有办法检查这些空白,可以用一些生成的div填充它们,并在其中填充一些数据。

I would play with offset().left. 我会玩offset()。left。 For example: 例如:

  1. Store a masonry item in variable "item" 将砌体项目存储在变量“ item”中
  2. Check if item.next().offset().left equals item.offset().left+item.outerWidth(true) 检查item.next()。offset()。left是否等于item.offset()。left + item.outerWidth(true)

That will check if the item next to our starting item is actually there . 那将检查我们开始的项目旁边的项目是否确实存在 Note that outerWidth(true) makes sure the margin between items is also counted. 请注意,outerWidth(true)确保还计算项目之间的边距。

Hope my theory makes sense to you, 希望我的理论对您有意义,
Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM