Javascript 砌体中的无限滚动
我不知道JavaScript,但我真的希望我的网站上有这个。 下面是我用于砌石的JavaScript。有人能告诉我如何让无限滚动工作吗?我用谷歌搜索了一下,运气不好Javascript 砌体中的无限滚动,javascript,html,jquery-masonry,infinite-scroll,Javascript,Html,Jquery Masonry,Infinite Scroll,我不知道JavaScript,但我真的希望我的网站上有这个。 下面是我用于砌石的JavaScript。有人能告诉我如何让无限滚动工作吗?我用谷歌搜索了一下,运气不好 <script> (function($){ //Finding min and max values in array from http://snippets.dzone.com/posts/show/769 Array.prototype.min = function(){ return Math.mi
<script>
(function($){
//Finding min and max values in array from http://snippets.dzone.com/posts/show/769
Array.prototype.min = function(){ return Math.min.apply({},this) };
Array.prototype.max = function(){ return Math.max.apply({},this) };
$.fn.masonry = function() {
this.each(function() {
var wall = $(this);
if ( wall.children().length > 0 ) { // check if the element has anything in it
if( wall.children('.masonryWrap').length == 0 ) { // checks if the masonryWrap div is already there
wall.wrapInner('<div class=\"masonryWrap\"></div>');
}
var mWrap = wall.children('.masonryWrap');
var brick = mWrap.children();
var brickW = brick.outerWidth(true);
var colCount = Math.floor( mWrap.width() / brickW ) ;
var colH=new Array();
for ( i=0; i < colCount; i++) {
colH[ i ] = 0 ;
}
mWrap.css({ position: 'relative' });
brick.css({
float: 'none',
position: 'absolute',
display: 'block'
})
.each(function(){
for ( i=colCount-1; i > -1; i-- ) {
if ( colH[ i ] == colH.min() ) {
var thisCol = i;
}
}
$(this).css({
top: colH[ thisCol ],
left: brickW * thisCol
});
colH[ thisCol ] += $(this).outerHeight(true);
});
mWrap.height( colH.max() );
}
return this;
});
};
})(jQuery);
</script>
(函数($){
//从中查找数组中的最小值和最大值http://snippets.dzone.com/posts/show/769
Array.prototype.min=function(){return Math.min.apply({},this)};
Array.prototype.max=function(){return Math.max.apply({},this)};
$.fn.mashise=函数(){
这个。每个(函数(){
var wall=$(此);
如果(wall.children().length>0){//检查元素中是否有任何内容
if(wall.children('.masonryWrap').length==0){//检查masonryWrap div是否已经存在
壁卷纸机(“”);
}
var mWrap=wall.children('.masonryWrap');
var brick=mWrap.children();
var brickkw=砖的外径(真);
var colCount=数学地板(mWrap.width()/brickkW);
var colH=新数组();
对于(i=0;i-1;i--){
if(colH[i]==colH.min()){
var-thisCol=i;
}
}
$(this.css)({
顶部:colH[thisCol],
左:brickkw*thisCol
});
colH[thisCol]+=$(this).outerHeight(true);
});
mWrap.height(colH.max());
}
归还这个;
});
};
})(jQuery);
或者使用其中一个已经内置了无限卷轴和砖石结构的主题,或者搜索更多。相信我,我以前也遇到过这个问题,现在已经有很多关于砖石和无限卷轴的帖子了。你能用你的代码设置一个新的吗?