2013-11-21 29 views
9

我试图找到一种方法来自动调整大小的网格容器。gridster,如何自动适应浏览器大小的变化?

以某种方式,当用户更改浏览器大小时,会调整相应的gridster窗口小部件的大小。 (在该行和列的数量没有变化,但实际大小会)

我可以计算出“widget_base_dimensions”作为浏览器的大小的变化值,

,但是我无法找到一个方法来更新/执行到小部件以应付新的大小。

我正在寻求是否有支持这种功能的函数,我注意到,

上jquery.gridster.js线3529,

/** 
* Recalculates the offsets for the faux grid. You need to use it when 
* the browser is resized. 
* 
* @method recalculate_faux_grid 
* @return {Object} Returns the instance of the Gridster class. 
*/ 
fn.recalculate_faux_grid = function() { 
    var aw = this.$wrapper.width(); 
    this.baseX = ($(window).width() - aw)/2; 
    this.baseY = this.$wrapper.offset().top; 

    $.each(this.faux_grid, $.proxy(function(i, coords) { 
     this.faux_grid[i] = coords.update({ 
      left: this.baseX + (coords.data.col -1) * this.min_widget_width, 
      top: this.baseY + (coords.data.row -1) * this.min_widget_height 
     }); 

    }, this)); 

    return this; 
}; 

我想一些如何利用它们但未能:(

如果有人已成功地使用这种代码或解决,你能帮帮我吗?

+0

你有什么好运气吗? – Cole

+0

应该在基本维度上定义manuel宽度'.gridster li {width:34%;}'百分比会使其适合屏幕 – Harish

+0

更好地使用Packery.js,gridster似乎不再受支持 – Denis

回答

2

有长期站立issue #5在Github上的项目问题追踪中,标题为自动刷新 - 响应式电网和其他几个关闭为重复项。在那里你会发现人们试图添加对网格的响应能力。

相关问题