@@ -145,6 +145,9 @@ Parameters:
145
145
- ` auto_position ` - if ` true ` then ` x ` , ` y ` parameters will be ignored and widget will be places on the first available
146
146
position
147
147
148
+ Widget will be always placed even if result height will be more then grid height. You need to use ` will_it_fit ` method
149
+ before call ` add_widget ` for additional check.
150
+
148
151
``` javascript
149
152
$ (' .grid-stack' ).gridstack ();
150
153
@@ -195,7 +198,22 @@ Enables/Disables moving.
195
198
196
199
- ` el ` - widget to modify
197
200
- ` val ` - if ` true ` widget will be draggable.
201
+
202
+ ### will_it_fit(x, y, width, height, auto_position)
203
+
204
+ Returns ` true ` if the ` height ` of the grid will be less the vertical constraint. Always returns ` true ` if grid doesn't
205
+ have ` height ` constraint.
206
+
207
+ ``` javascript
208
+ if (grid .will_it_fit (new_node .x , new_node .y , new_node .width , new_node .height , true )) {
209
+ grid .add_widget (new_node .x , new_node .y , new_node .width , new_node .height , true );
210
+ }
211
+ else {
212
+ alert (' Not enough free space to please the widget' );
213
+ }
214
+ ```
198
215
216
+
199
217
## Utils
200
218
201
219
### GridStackUI.Utils.sort(nodes, \[ dir\] , \[ width\] )
@@ -265,6 +283,8 @@ Changes
265
283
266
284
#### v0.2.1 (Current development version)
267
285
286
+ - add ` will_it_fit ` API method
287
+ - fix auto-positioning (issue #20 )
268
288
- add animation (thanks to @ishields )
269
289
- fix ` y ` coordinate calculation when dragging (issue #18 )
270
290
- fix ` remove_widget ` (issue #16 )
0 commit comments