gridster,如何自动适应浏览器大小的变化

gridster, how to auto fit to browser size change?

本文关键字:变化 浏览器 何自动 gridster      更新时间:2023-09-26

我正试图找到一种自动调整网格容器大小的方法。

在某种程度上,当用户更改浏览器大小时,相应的欺诈小部件会调整大小。(其中列和行的数量不会改变,但实际大小会改变)

随着浏览器大小的变化,我可以计算"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;
};

我尝试了一些如何利用它们,但失败了:(

如果有人成功地使用了这个代码或解决了这个问题,你能帮助我吗?

Github项目的问题跟踪集中有一个长期存在的问题#5,标题为自动刷新-响应网格,其他几个问题以重复形式关闭。在那里,你会发现一些人发布的代码试图为欺诈者增加响应能力。