Skip to content

Commit 2fd2cce

Browse files
committed
updated doc
1 parent 722dd87 commit 2fd2cce

File tree

2 files changed

+51
-25
lines changed

2 files changed

+51
-25
lines changed

.vscode/settings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"cSpell.words": [
3+
"Pavel",
4+
"Reznikov",
5+
"doctoc",
6+
"drag'n'drop",
7+
"dragdrop",
8+
"draggable",
9+
"dragstart",
10+
"dragstop",
11+
"dropover",
12+
"droppable",
13+
"gsresize",
14+
"gsresizestop",
15+
"jqueryui",
16+
"resizestart"
17+
]
18+
}

doc/README.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ gridstack.js API
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8-
- [Options](#options)
8+
- [Grid Options](#grid-options)
99
- [Grid attributes](#grid-attributes)
10+
- [Item Options](#item-options)
1011
- [Item attributes](#item-attributes)
1112
- [Events](#events)
1213
- [added(event, items)](#addedevent-items)
@@ -60,23 +61,26 @@ gridstack.js API
6061

6162
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
6263

63-
## Options
64+
## Grid Options
6465

6566
- `acceptWidgets` - accept widgets dragged from other grids or from outside (default: `false`). Can be:
6667
* `true` (uses `'.grid-stack-item'` class filter) or `false`
6768
* string for explicit class name
68-
* function (i: number, element: Element) returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
69-
- `alwaysShowResizeHandle` - if `true` the resizing handles are shown even if the user is not hovering over the widget
70-
(default: `false`)
69+
* `function (i: number, element: Element): boolean` See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
70+
- `alwaysShowResizeHandle` - possible values (default: `false` only show on hover)
71+
* `true` the resizing handles are always shown even if the user is not hovering over the widget
72+
* advance condition such as this mobile browser agent check:
73+
`alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent )`
74+
See [example](http://gridstack.github.io/gridstack.js/demo/advance.html)
7175
- `animate` - turns animation on (default: `false`)
7276
- `auto` - if `false` gridstack will not initialize existing items (default: `true`)
7377
- `cellHeight` - one cell height (default: `60`). Can be:
7478
* an integer (px)
7579
* a string (ex: '100px', '10em', '10rem', '10%')
7680
* 0 or null, in which case the library will not generate styles for rows. Everything must be defined in CSS files.
77-
* `'auto'` - height will be calculated to match cell width (initial square grid).
81+
* `'auto'` - height will be calculated cell square initially.
7882
- `column` - number of columns (default: `12`) which can change on the fly with `column(N)` as well. See [example](http://gridstackjs.com/demo/column.html)
79-
- `ddPlugin` - class that implement drag'n'drop functionallity for gridstack. If `false` grid will be static. (default: `null` - first available plugin will be used)
83+
- `ddPlugin` - class that implement drag'n'drop functionality for gridstack. If `false` grid will be static. (default: `null` - first available plugin will be used)
8084
- `disableDrag` - disallows dragging of widgets (default: `false`).
8185
- `disableOneColumnMode` - disables the onColumnMode when the window width is less than minWidth (default: 'false')
8286
- `disableResize` - disallows resizing of widgets (default: `false`).
@@ -87,7 +91,7 @@ gridstack.js API
8791
- `handleClass` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`)
8892
- `itemClass` - widget class (default: `'grid-stack-item'`)
8993
- `maxRow` - maximum rows amount. Default is `0` which means no max.
90-
- `minRow` - minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute on the grid div in pixels, which will round to the closest row.
94+
- `minRow` - minimum rows amount which is handy to prevent grid from collapsing when empty. Default is `0`. You can also do this with `min-height` CSS attribute on the grid div in pixels, which will round to the closest row.
9195
- `minWidth` - minimal width. If window width is less than or equal to, grid will be shown in one-column mode (default: `768`)
9296
- `oneColumnModeDomSort` - set to `true` if you want oneColumnMode to use the DOM order and ignore x,y from normal multi column layouts during sorting. This enables you to have custom 1 column layout that differ from the rest. (default?: `false`)
9397
- `placeholderClass` - class for placeholder (default: `'grid-stack-placeholder'`)
@@ -104,26 +108,30 @@ gridstack.js API
104108

105109
## Grid attributes
106110

107-
- `data-gs-animate` - turns animation on
108-
- `data-gs-column` - amount of columns. Setting non-default value must be supported by equivalent change in CSS, [see docs here](https://github.com/gridstack/gridstack.js#change-grid-columns).
111+
most of the above options are also available as HTML attributes using the `data-gs-` name prefix with standard dash lower case naming convention (ex: `data-gs-column`, `data-gs-min-row`, etc..).
112+
113+
Extras:
109114
- `data-gs-current-row` - (internal) current rows amount. Set by the library only. Can be used by the CSS rules.
110-
- `data-gs-max-row` - maximum rows amount. Default is `0` which means no max.
111-
- `data-gs-min-row` - minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute on the grid div in pixels, which will round to the closest row.
112-
- `data-gs-row` - fix grid number of rows. This is a shortcut of writing `data-gs-min-row="N" data-gs-max-row="N"`. (default `0` no constrain)
115+
116+
## Item Options
117+
118+
options you can pass when calling `addWidget()`
119+
120+
- `autoPosition` - tells to ignore `x` and `y` attributes and to place element to the first available position. Having either one missing will also do that.
121+
- `x`, `y` - (number) element position in row/column. Note: if one is missing this will `autoPosition` the item
122+
- `width`, `height` - (number) element size in row/column (default 1x1)
123+
- `maxWidth`, `minWidth`, `maxHeight`, `minHeight` - element constraints in row/column (default none)
124+
- `locked` - means another widget wouldn't be able to move it during dragging or resizing.
125+
The widget can still be dragged or resized by the user.
126+
You need to add `noResize` and `noMove` attributes to completely lock the widget.
127+
- `noResize` - disable element resizing
128+
- `noMove` - disable element moving
129+
- `resizeHandles` - sets resize handles for a specific widget.
130+
- `id`- (number | string) good for quick identification (for example in change event)
113131

114132
## Item attributes
115133

116-
- `data-gs-x`, `data-gs-y` - (number) element position in row/column. Note: if one is missing this will `autoPosition` the item
117-
- `data-gs-width`, `data-gs-height` - (number) element size in row/column
118-
- `data-gs-id`- (number | string) good for quick identification (for example in change event)
119-
- `data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints in row/column
120-
- `data-gs-no-resize` - disable element resizing
121-
- `data-gs-no-move` - disable element moving
122-
- `data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first available position. Having either one missing will also do that.
123-
- `data-gs-locked` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing.
124-
The widget can still be dragged or resized. You need to add `data-gs-no-resize` and `data-gs-no-move` attributes
125-
to completely lock the widget.
126-
- `data-gs-resize-handles` - sets resize handles for a specific widget.
134+
all item options are also available as HTML attributes using the `data-gs-` name prefix with standard dash lower case naming convention (ex: `data-gs-x`, `data-gs-min-width`, etc..).
127135

128136
## Events
129137

@@ -263,7 +271,7 @@ starts batch updates. You will see no changes until `commit()` method is called.
263271

264272
### compact()
265273

266-
relayout grid items to reclaim any empty space.
274+
re-layout grid items to reclaim any empty space.
267275

268276
### cellHeight()
269277

0 commit comments

Comments
 (0)