2

我想在一页中使用几个同位素实例。其中一个实例是角落印章,而其他实例是常规的“砌体”印章

我想用新名称重命名cornerstamp - homeMasonry

如果我从http://isotope.metafizzy.co/docs/extending-isotope.html重命名这两个函数,我会遇到一个Uncaught TypeError: Cannot set property 'cols' of undefined

这是2个功能

  $.Isotope.prototype._homeMasonryReset = function() {
    // layout-specific props
    this.masonry = {};
    this._getSegments();
    var i = this.masonry.cols;
    this.masonry.colYs = [];
    while (i--) {
      this.masonry.colYs.push( 0 );
    }

    if ( this.options.masonry.cornerStampSelector ) {
      var $cornerStamp = this.element.find( this.options.masonry.cornerStampSelector ),
          stampWidth = $cornerStamp.outerWidth(true) - ( this.element.width() % this.masonry.columnWidth ),
          cornerCols = Math.ceil( stampWidth / this.masonry.columnWidth ),
          cornerStampHeight = $cornerStamp.outerHeight(true);
      for ( i = Math.max( this.masonry.cols - cornerCols, cornerCols ); i < this.masonry.cols; i++ ) {
        this.masonry.colYs[i] = cornerStampHeight;
      }
    }
  };

    $.Isotope.prototype._homeMasonryResizeChanged = function() {
    return true;
  };

和同位素调用

 $container.isotope({
      layoutMode: 'homeMasonry',
    itemSelector: '.item',
      homeMasonry: {cornerStampSelector: '.corner'}
  });

我用 jsfiddle 重新创建了这个问题

http://jsfiddle.net/DQydj/133/

看来同位素不喜欢我的重命名。有谁知道出了什么问题?

4

1 回答 1

0

除了重命名布局函数外,您还必须重命名引用原始砌体对象的变量。换句话说this.masonry,必须更改为this.homeMasonry.

于 2013-03-14T01:22:28.930 回答