2013-11-21 32 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上的項目問題追蹤中,標題爲自動刷新 - 響應式電網和其他幾個關閉爲重複項。在那裏你會發現人們試圖添加對網格的響應能力。

相關問題