You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+275-9Lines changed: 275 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,14 +43,16 @@ TODO UPDATE DOCS
43
43
* Automatic RTL support
44
44
45
45
46
-
## Installation
46
+
## Getting Started
47
+
48
+
### Installation
47
49
48
50
Install the vue-grid-layout [package](https://www.npmjs.org/package/vue-grid-layout) package using [npm](https://www.npmjs.com/):
49
51
50
52
npm install vue-grid-layout
51
53
52
54
53
-
## Usage
55
+
###Usage
54
56
55
57
npm install vue-grid-layout
56
58
@@ -126,10 +128,254 @@ or include the script in your html (download from [releases](https://github.com/
126
128
</grid-layout>
127
129
````
128
130
129
-
<!-- TODO DOCUMENTAR PROPS DE GridLayout E GridItem -->
130
131
132
+
### Documentation
133
+
134
+
#### Properties
135
+
136
+
##### GridLayout
137
+
138
+
* **layout**
139
+
140
+
* type: `Array`
141
+
* required: `true`
142
+
143
+
This is the initial layout of the grid.
144
+
145
+
The value must be an `Array` of `Object` items. Each item must have `i`, `x`, `y`, `w` and `h` proprties. Please refer to `GridItem` documentation below for more informations.
146
+
147
+
* **colNum**
148
+
149
+
* type: `Number`
150
+
* required: `false`
151
+
* default: `12`
152
+
153
+
Says how many columns the grid has.
154
+
155
+
The value should be a _natural number_.
156
+
157
+
* **rowHeight**
158
+
159
+
* type: `Number`
160
+
* required: `false`
161
+
* default: `150`
162
+
163
+
Says what is a height of a single row in pixels.
164
+
165
+
* **maxRows**
166
+
167
+
* type: `Number`
168
+
* required: `false`
169
+
* default: `Infinity`
170
+
171
+
Says what is a maximal number of rows in the grid.
172
+
173
+
* **margin**
174
+
175
+
* type: `Array`
176
+
* required: `false`
177
+
* default: `[10, 10]`
178
+
179
+
Says what are the margins of elements inside the grid.
180
+
181
+
The value must be a two-element `Array` of `Number`. Each value is expressed in pixels. The first element is a margin horizontally, the second element is a vertical margin.
182
+
183
+
* **isDraggable**
184
+
185
+
* type: `Boolean`
186
+
* required: `false`
187
+
* default: `true`
188
+
189
+
Says if the grids items are draggable.
190
+
191
+
* **isResizable**
192
+
193
+
* type: `Boolean`
194
+
* required: `false`
195
+
* default: `true`
196
+
197
+
Says if the grids items are resizable.
198
+
199
+
* **isMirrored**
200
+
201
+
* type: `Boolean`
202
+
* required: `false`
203
+
* default: `false`
204
+
205
+
Says if the RTL/LTR should be reversed.
206
+
207
+
* **autoSize**
208
+
209
+
* type: `Boolean`
210
+
* required: `false`
211
+
* default: `true`
212
+
213
+
Says if the container height should swells and contracts to fit contents.
214
+
215
+
* **verticalCompact**
216
+
217
+
* type: `Boolean`
218
+
* required: `false`
219
+
* default: `true`
220
+
221
+
Says if the layout should be compact vertically.
222
+
223
+
* **useCssTransforms**
224
+
225
+
* type: `Boolean`
226
+
* required: `false`
227
+
* default: `true`
228
+
229
+
Says if the CSS `transition-property: transform;` should be used.
230
+
231
+
232
+
233
+
##### GridItem
234
+
235
+
* **i**
236
+
237
+
* type: `String`
238
+
* required: `true`
239
+
240
+
This is the unique identifier of the item.
241
+
242
+
* **x**
243
+
244
+
* type: `Number`
245
+
* required: `true`
246
+
247
+
Says what is a initial horizontal position of the item (in which column it should be placed).
248
+
249
+
The value must be a _whole number_.
250
+
251
+
* **y**
252
+
253
+
* type: `Number`
254
+
* required: `true`
255
+
256
+
Says what is a initial vertical position of the item (in which row it should be placed).
257
+
258
+
The value must be a _whole number_.
259
+
260
+
* **w**
261
+
262
+
* type: `Number`
263
+
* required: `true`
264
+
265
+
Says what is a initial width of the item.
266
+
267
+
The value is a number that is multiplied by `colWidth`.
268
+
269
+
* **h**
270
+
271
+
* type: `Number`
272
+
* required: `true`
273
+
274
+
Says what is a initial height of the item.
131
275
132
-
### Events
276
+
The value is a number that is multiplied by `rowHeight`.
277
+
278
+
* **minW**
279
+
280
+
* type: `Number`
281
+
* required: `false`
282
+
* default: `1`
283
+
284
+
Says what is a minimal width of the item. If `w` will be smaller then `minW` then `w` will be set to `minW`.
285
+
286
+
The value is a number that is multiplied by `colWidth`.
287
+
288
+
* **minH**
289
+
290
+
* type: `Number`
291
+
* required: `false`
292
+
* default: `1`
293
+
294
+
Says what is a minimal hieght of the item. If `h` will be smaller then `minH` then `h` will be set to `minH`.
295
+
296
+
The value is a number that is multiplied by `rowHeight`.
297
+
298
+
* **maxW**
299
+
300
+
* type: `Number`
301
+
* required: `false`
302
+
* default: `Infinity`
303
+
304
+
Says what is a maximal width of the item. If `w` will be bigger then `maxW` then `w` will be set to `maxW`.
305
+
306
+
The value is a number that is multiplied by `colWidth`.
307
+
308
+
* **maxH**
309
+
310
+
* type: `Number`
311
+
* required: `false`
312
+
* default: `Infinity`
313
+
314
+
Says what is a maximal height of the item. If `h` will be bigger then `maxH` then `h` will be set to `maxH`.
315
+
316
+
The value is a number that is multiplied by `rowHeight`
317
+
318
+
* **isDraggable**
319
+
320
+
* type: `Boolean`
321
+
* required: `false`
322
+
* default: `null`
323
+
324
+
Says if item is draggable.
325
+
326
+
If default value is `null` then it's inherited from parent.
327
+
328
+
* **isResizable**
329
+
330
+
* type: `Boolean`
331
+
* required: `false`
332
+
* default: `null`
333
+
334
+
Says if item is resizable.
335
+
336
+
If default value is `null` then it's inherited from parent.
337
+
338
+
* **dragIgnoreFrom**
339
+
340
+
* type: `String`
341
+
* required: `false`
342
+
* default: `'a, button'`
343
+
344
+
Says which elements of the item shouldn't trigger drag event of the item.
345
+
346
+
The value is `css-like` selector string.
347
+
348
+
For more info please refer to `ignoreFrom` in [interact.js docs](http://interactjs.io/docs/#ignorable-selectors).
349
+
350
+
* **dragAllowFrom**
351
+
352
+
* type: `String`
353
+
* required: `false`
354
+
* default: `null`
355
+
356
+
Says which elements of the item should trigger drag event of the item.
357
+
358
+
The value is `css-like` selector string.
359
+
360
+
If `null` then one can drag by any (excluding `dragIgnoreFrom`) element of the item.
361
+
362
+
For more info please refer to `allowFrom` in [interact.js docs](http://interactjs.io/docs/#ignorable-selectors).
363
+
364
+
* **resizeIgnoreFrom**
365
+
366
+
* type: `String`
367
+
* required: `false`
368
+
* default: `'a, button'`
369
+
370
+
Says which elements of the item shouldn't trigger resize event of the item.
371
+
372
+
The value is `css-like` selector string.
373
+
374
+
For more info please refer to `ignoreFrom` in [interact.js docs](http://interactjs.io/docs/#ignorable-selectors).
375
+
376
+
377
+
378
+
#### Events
133
379
134
380
Move and resize event listeners can be added to each grid-item, so that the parent Vue can be notified when a grid element is being moved or resized.
135
381
Moved and resized event listeners can be added, if the only notification needed is when an item is finished moving or resizing.
@@ -165,39 +411,59 @@ Working example [here](https://jbaysolutions.github.io/vue-grid-layout/examples/
165
411
</grid-layout>
166
412
````
167
413
168
-
* Layout updated event: every time the layout has finished updating and positions of all grid-items are recalculated
414
+
* **layoutUpdatedEvent**
415
+
416
+
Layout updated event
417
+
418
+
Every time the layout has finished updating and positions of all grid-items are recalculated
169
419
170
420
```javascript
171
421
layoutUpdatedEvent: function(newLayout){
172
422
console.log("Updated layout: ", newLayout)
173
423
}
174
424
```
175
425
176
-
* Move event: every time an item is being moved and changes position
426
+
***moveEvent**
427
+
428
+
Move event
429
+
430
+
Every time an item is being moved and changes position
177
431
178
432
```javascript
179
433
moveEvent:function(i, newX, newY){
180
434
console.log("MOVE i="+ i +", X="+ newX +", Y="+ newY);
181
435
},
182
436
```
183
437
184
-
* Resize event: every time an item is being resized and changes size
438
+
***resizeEvent**
439
+
440
+
Resize event
441
+
442
+
Every time an item is being resized and changes size
185
443
186
444
```javascript
187
445
resizeEvent:function(i, newH, newW){
188
446
console.log("RESIZE i="+ i +", H="+ newH +", W="+ newW);
189
447
},
190
448
```
191
449
192
-
* Moved event: every time an item is finished being moved and changes position
450
+
***movedEvent**
451
+
452
+
Moved event
453
+
454
+
Every time an item is finished being moved and changes position
193
455
194
456
```javascript
195
457
movedEvent:function(i, newX, newY){
196
458
console.log("MOVED i="+ i +", X="+ newX +", Y="+ newY);
197
459
},
198
460
```
199
461
200
-
* Resized event: every time an item is finished being resized and changes size
462
+
***resizedEvent**
463
+
464
+
Resized event
465
+
466
+
Every time an item is finished being resized and changes size
0 commit comments