Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript gridster,如何自动适应浏览器大小的变化?_Javascript_Jquery_Gridster - Fatal编程技术网

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

Javascript gridster,如何自动适应浏览器大小的变化?,javascript,jquery,gridster,Javascript,Jquery,Gridster,我正试图找到一种自动调整gridster容器大小的方法 在某种程度上,当用户更改浏览器大小时,相应的gridster小部件会调整大小。 (列数和行数不变,但实际大小不变) 随着浏览器大小的变化,我可以计算“widget\u base\u dimensions”的值 然而,我找不到一种方法来更新/执行小部件以适应新的大小 我在寻找是否有一个函数支持这种特性,我注意到 在jquery.gridster.js的第3529行 /** * Recalculates the offsets for the

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

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

随着浏览器大小的变化,我可以计算“widget\u base\u 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的项目问题跟踪上有一个长期存在的问题,名为“自动刷新-响应网格”,其他几个问题以重复形式关闭。在那里,你会发现试图向gridster添加响应性的人发布的代码。

你运气好吗用这个?应该定义基本维度上的manuel宽度
.gridster li{width:34%;}
percentage将使其更适合screenbetter使用packer.js,gridster似乎不再受支持。您对此有什么运气吗?我最近遇到了容器宽度问题,并在gridster源代码中发现了相同的函数,但在使用它时没有乐趣…我在GitHub上提出了一个问题,但还没有得到任何结果。。。