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

Skip to content

Commit 444909d

Browse files
committed
update docs
1 parent 48c1bf1 commit 444909d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ Parameters:
145145
- `auto_position` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available
146146
position
147147

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+
148151
```javascript
149152
$('.grid-stack').gridstack();
150153

@@ -195,7 +198,22 @@ Enables/Disables moving.
195198

196199
- `el` - widget to modify
197200
- `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+
```
198215

216+
199217
## Utils
200218

201219
### GridStackUI.Utils.sort(nodes, \[dir\], \[width\])
@@ -265,6 +283,8 @@ Changes
265283

266284
#### v0.2.1 (Current development version)
267285

286+
- add `will_it_fit` API method
287+
- fix auto-positioning (issue #20)
268288
- add animation (thanks to @ishields)
269289
- fix `y` coordinate calculation when dragging (issue #18)
270290
- fix `remove_widget` (issue #16)

0 commit comments

Comments
 (0)