我正在尝试找到一种自动调整 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;
};
我尝试了一些如何利用它们但失败了:(
如果有人成功使用此代码或解决问题,您能帮帮我吗?