グリッドスターコンテナーのサイズを自動変更する方法を見つけようとしています。
ユーザーがブラウザのサイズを変更すると、対応する 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;
};
私はそれらをどのように利用しようとしましたが、失敗しました:(
誰かがこのコードをうまく利用したり、回避したりした場合は、助けてもらえますか?