2012-11-21 68 views
0

我使用了jQuery砌體腳本。在那個劇本中我使用了Corner郵票。我的代碼像波紋管。jQuery.Mason在jQuery砌體中未定義

jQuery.Mason.prototype.resize = function() { 
    this._getColumns(); 
    this._reLayout(); 
    }; 

    jQuery.Mason.prototype._reLayout = function(callback) { 
    var freeCols = this.cols; 
    if (this.options.cornerStampSelector) { 

     var containerWidth = this.cols * this.columnWidth - this.options.gutterWidth; 
     this.element.css({ width: containerWidth }); 

     var $cornerStamp = this.element.find(this.options.cornerStampSelector), 
      cornerStampX = $cornerStamp.offset().left - 
      (this.element.offset().left + this.offset.x + parseInt($cornerStamp.css('marginLeft'))); 
     freeCols = Math.floor(cornerStampX/this.columnWidth); 
    } 
    // reset columns 
    var i = this.cols; 
    this.colYs = []; 
    while (i--) { 
     this.colYs.push(this.offset.y); 
    } 

    for (i = freeCols; i < this.cols; i++) { 
     this.colYs[i] = this.offset.y + $cornerStamp.outerHeight(true); 
    } 

    // apply layout logic to all bricks 
    this.layout(this.$bricks, callback); 
    }; 

但現在它顯示「jQuery.Mason未定義」。我的代碼有什麼問題請給我建議。

回答

0

我的代碼有類似的問題。我遵循masonry.desandro.com的指示,但腳本無法使用jQuery 1.8.3。

我改變了$ .Mason.prototype._reLayout功能如下:

$.Mason.prototype._reLayout = function(callback) { 
var freeCols = this.cols; 
if (this.options.cornerStampSelector) { 
    //jQuery Selector 
    var cornerStamp = $(this.options.cornerStampSelector); 
    var cornerStampX = cornerStamp.offset().left - (this.element.offset().left + this.offset.x + parseInt(cornerStamp.css('marginLeft'))); 
    var freeCols = Math.floor(cornerStampX/this.columnWidth); 
} 
//Reset columns 
var i = this.cols; 
this.colYs = []; 
while (i--) { 
    this.colYs.push(this.offset.y); 
} 
for (i = freeCols; i < this.cols; i++) { 
    this.colYs[i] = this.offset.y + cornerStamp.outerHeight(true); 
} 
//Apply layout logic to all bricks 
this.layout(this.$bricks, callback); }; 

提供你的CSS類似於在磚石示例代碼工作設定!