Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fae198f

Browse files
try_moving_tile_y
1 parent 55ac138 commit fae198f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/gridstack.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@
516516
_class: 'grid-stack-' + (Math.random() * 10000).toFixed(0),
517517
animate: Boolean(this.container.attr('data-gs-animate')) || false,
518518
always_show_resize_handle: false,
519-
static_class: 'grid-stack-static'
519+
static_class: 'grid-stack-static',
520+
y_fit_increment: 1
520521
};
521522

522523
opts = _.defaults(opts, defaults);
@@ -976,6 +977,28 @@
976977
this.will_it_fit(x, y, width, height, auto_position);
977978
};
978979

980+
GridStack.prototype.try_moving_tile_y = function(x, y, width, height, rows) {
981+
var increment_y = 0,
982+
max_y = rows - height,
983+
fitting_y = y,
984+
fitted_previously = false;
985+
986+
while (increment_y <= max_y) {
987+
var it_will_fit = this.is_area_empty_and_will_it_fit(x, increment_y, width, height, false);
988+
if (it_will_fit) {
989+
if (!fitted_previously) {
990+
fitting_y = increment_y;
991+
fitted_previously = true;
992+
}
993+
} else {
994+
fitted_previously = false;
995+
}
996+
increment_y += this.opts.y_fit_increment;
997+
}
998+
999+
return fitting_y;
1000+
};
1001+
9791002
GridStack.prototype.set_static = function(static_value) {
9801003
this.opts.static_grid = (static_value === true);
9811004
this._set_static_class();

0 commit comments

Comments
 (0)