0

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 is undefined」と表示されました。私のコードの問題は何ですか?私に提案してください。

4

1 に答える 1

0

コードにも同様の問題がありました。masonry.desandro.comの指示に従いましたが、 jQuery1.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があれば、コードは機能します。

于 2013-02-06T12:57:29.493 に答える