9

グリッドスターコンテナーのサイズを自動変更する方法を見つけようとしています。

ユーザーがブラウザのサイズを変更すると、対応する 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;
};

私はそれらをどのように利用しようとしましたが、失敗しました:(

誰かがこのコードをうまく利用したり、回避したりした場合は、助けてもらえますか?

4

1 に答える 1

2

Github のプロジェクトの問題トラックに長年の問題 #5があり、タイトルはAuto refresh - Responsive gridで、その他のいくつかは重複として閉じられています。そこでは、gridster に応答性を追加しようとしている人々によって投稿されたコードが見つかります。

于 2014-07-31T12:32:35.167 に答える