0

我不知道 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.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>
4

1 回答 1

0

要么使用这些主题之一http://zen-themes.tumblr.com/已经内置了无限滚动和砖石,要么搜索更多。相信我,我以前遇到过这个问题,并且已经有大量关于砖石和无限滚动的帖子。

于 2013-08-14T20:54:05.243 回答