@@ -14,6 +14,7 @@ or autogenerated.
14
14
RGL is React-only and does not require jQuery.
15
15
16
16
![ BitMEX UI] ( http://i.imgur.com/oo1NT6c.gif )
17
+
17
18
> GIF from production usage on [ BitMEX.com] ( https://www.bitmex.com )
18
19
19
20
[ ** [ Demo] ( https://react-grid-layout.github.io/react-grid-layout/ ) | [ Changelog] ( /CHANGELOG.md ) | [ CodeSandbox Editable demo] ( https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js ) ** ]
@@ -77,32 +78,32 @@ RGL is React-only and does not require jQuery.
77
78
- [ Statsout] ( https://statsout.com/ )
78
79
- [ Datto RMM] ( https://www.datto.com/uk/products/rmm/ )
79
80
80
- * Know of others? Create a PR to let me know!*
81
+ _ Know of others? Create a PR to let me know!_
81
82
82
83
## Features
83
84
84
- * 100% React - no jQuery
85
- * Compatible with server-rendered apps
86
- * Draggable widgets
87
- * Resizable widgets
88
- * Static widgets
89
- * Configurable packing: horizontal, vertical, or off
90
- * Bounds checking for dragging and resizing
91
- * Widgets may be added or removed without rebuilding grid
92
- * Layout can be serialized and restored
93
- * Responsive breakpoints
94
- * Separate layouts per responsive breakpoint
95
- * Grid Items placed using CSS Transforms
96
- * Performance with CSS Transforms: [ on] ( http://i.imgur.com/FTogpLp.jpg ) / [ off] ( http://i.imgur.com/gOveMm8.jpg ) , note paint (green) as % of time
97
- * Compatibility with ` <React.StrictMode> `
98
-
99
- | Version | Compatibility |
100
- | ---------------- | ------------------ |
101
- | >= 0.17.0 | React 16 & 17 |
102
- | >= 0.11.3 | React 0.14 & 15 |
103
- | >= 0.10.0 | React 0.14 |
104
- | 0.8. - 0.9.2 | React 0.13 |
105
- | < 0.8 | React 0.12 |
85
+ - 100% React - no jQuery
86
+ - Compatible with server-rendered apps
87
+ - Draggable widgets
88
+ - Resizable widgets
89
+ - Static widgets
90
+ - Configurable packing: horizontal, vertical, or off
91
+ - Bounds checking for dragging and resizing
92
+ - Widgets may be added or removed without rebuilding grid
93
+ - Layout can be serialized and restored
94
+ - Responsive breakpoints
95
+ - Separate layouts per responsive breakpoint
96
+ - Grid Items placed using CSS Transforms
97
+ - Performance with CSS Transforms: [ on] ( http://i.imgur.com/FTogpLp.jpg ) / [ off] ( http://i.imgur.com/gOveMm8.jpg ) , note paint (green) as % of time
98
+ - Compatibility with ` <React.StrictMode> `
99
+
100
+ | Version | Compatibility |
101
+ | ------------ | --------------- |
102
+ | >= 0.17.0 | React 16 & 17 |
103
+ | >= 0.11.3 | React 0.14 & 15 |
104
+ | >= 0.10.0 | React 0.14 |
105
+ | 0.8. - 0.9.2 | React 0.13 |
106
+ | < 0.8 | React 0.12 |
106
107
107
108
## Installation
108
109
@@ -129,41 +130,53 @@ produce a grid with three items where:
129
130
- users will be able to freely drag and resize item ` c `
130
131
131
132
``` js
132
- import GridLayout from ' react-grid-layout' ;
133
+ import GridLayout from " react-grid-layout" ;
133
134
134
135
class MyFirstGrid extends React .Component {
135
136
render () {
136
137
// layout is an array of objects, see the demo for more complete usage
137
138
const layout = [
138
- {i: ' a ' , x: 0 , y: 0 , w: 1 , h: 2 , static: true },
139
- {i: ' b ' , x: 1 , y: 0 , w: 3 , h: 2 , minW: 2 , maxW: 4 },
140
- {i: ' c ' , x: 4 , y: 0 , w: 1 , h: 2 }
139
+ { i: " a " , x: 0 , y: 0 , w: 1 , h: 2 , static: true },
140
+ { i: " b " , x: 1 , y: 0 , w: 3 , h: 2 , minW: 2 , maxW: 4 },
141
+ { i: " c " , x: 4 , y: 0 , w: 1 , h: 2 }
141
142
];
142
143
return (
143
- < GridLayout className= " layout" layout= {layout} cols= {12 } rowHeight= {30 } width= {1200 }>
144
+ < GridLayout
145
+ className= " layout"
146
+ layout= {layout}
147
+ cols= {12 }
148
+ rowHeight= {30 }
149
+ width= {1200 }
150
+ >
144
151
< div key= " a" > a< / div>
145
152
< div key= " b" > b< / div>
146
153
< div key= " c" > c< / div>
147
154
< / GridLayout>
148
- )
155
+ );
149
156
}
150
157
}
151
158
```
152
159
153
160
You may also choose to set layout properties directly on the children:
154
161
155
162
``` js
156
- import GridLayout from ' react-grid-layout' ;
163
+ import GridLayout from " react-grid-layout" ;
157
164
158
165
class MyFirstGrid extends React .Component {
159
166
render () {
160
167
return (
161
168
< GridLayout className= " layout" cols= {12 } rowHeight= {30 } width= {1200 }>
162
- < div key= " a" data- grid= {{x: 0 , y: 0 , w: 1 , h: 2 , static: true }}> a< / div>
163
- < div key= " b" data- grid= {{x: 1 , y: 0 , w: 3 , h: 2 , minW: 2 , maxW: 4 }}> b< / div>
164
- < div key= " c" data- grid= {{x: 4 , y: 0 , w: 1 , h: 2 }}> c< / div>
169
+ < div key= " a" data- grid= {{ x: 0 , y: 0 , w: 1 , h: 2 , static: true }}>
170
+ a
171
+ < / div>
172
+ < div key= " b" data- grid= {{ x: 1 , y: 0 , w: 3 , h: 2 , minW: 2 , maxW: 4 }}>
173
+ b
174
+ < / div>
175
+ < div key= " c" data- grid= {{ x: 4 , y: 0 , w: 1 , h: 2 }}>
176
+ c
177
+ < / div>
165
178
< / GridLayout>
166
- )
179
+ );
167
180
}
168
181
}
169
182
```
@@ -178,21 +191,24 @@ excludes `React`, so it must be otherwise available in your application, either
178
191
To make RGL responsive, use the ` <ResponsiveReactGridLayout> ` element:
179
192
180
193
``` js
181
- import { Responsive as ResponsiveGridLayout } from ' react-grid-layout' ;
194
+ import { Responsive as ResponsiveGridLayout } from " react-grid-layout" ;
182
195
183
196
class MyResponsiveGrid extends React .Component {
184
197
render () {
185
198
// {lg: layout1, md: layout2, ...}
186
199
const layouts = getLayoutsFromSomewhere ();
187
200
return (
188
- < ResponsiveGridLayout className= " layout" layouts= {layouts}
189
- breakpoints= {{lg: 1200 , md: 996 , sm: 768 , xs: 480 , xxs: 0 }}
190
- cols= {{lg: 12 , md: 10 , sm: 6 , xs: 4 , xxs: 2 }}>
201
+ < ResponsiveGridLayout
202
+ className= " layout"
203
+ layouts= {layouts}
204
+ breakpoints= {{ lg: 1200 , md: 996 , sm: 768 , xs: 480 , xxs: 0 }}
205
+ cols= {{ lg: 12 , md: 10 , sm: 6 , xs: 4 , xxs: 2 }}
206
+ >
191
207
< div key= " 1" > 1 < / div>
192
208
< div key= " 2" > 2 < / div>
193
209
< div key= " 3" > 3 < / div>
194
210
< / ResponsiveGridLayout>
195
- )
211
+ );
196
212
}
197
213
}
198
214
```
@@ -215,7 +231,7 @@ positions on drag events. In simple cases a HOC `WidthProvider` can be used to a
215
231
width upon initialization and window resize events.
216
232
217
233
``` js
218
- import { Responsive , WidthProvider } from ' react-grid-layout' ;
234
+ import { Responsive , WidthProvider } from " react-grid-layout" ;
219
235
220
236
const ResponsiveGridLayout = WidthProvider (Responsive);
221
237
@@ -224,14 +240,17 @@ class MyResponsiveGrid extends React.Component {
224
240
// {lg: layout1, md: layout2, ...}
225
241
var layouts = getLayoutsFromSomewhere ();
226
242
return (
227
- < ResponsiveGridLayout className= " layout" layouts= {layouts}
228
- breakpoints= {{lg: 1200 , md: 996 , sm: 768 , xs: 480 , xxs: 0 }}
229
- cols= {{lg: 12 , md: 10 , sm: 6 , xs: 4 , xxs: 2 }}>
243
+ < ResponsiveGridLayout
244
+ className= " layout"
245
+ layouts= {layouts}
246
+ breakpoints= {{ lg: 1200 , md: 996 , sm: 768 , xs: 480 , xxs: 0 }}
247
+ cols= {{ lg: 12 , md: 10 , sm: 6 , xs: 4 , xxs: 2 }}
248
+ >
230
249
< div key= " 1" > 1 < / div>
231
250
< div key= " 2" > 2 < / div>
232
251
< div key= " 3" > 3 < / div>
233
252
< / ResponsiveGridLayout>
234
- )
253
+ );
235
254
}
236
255
}
237
256
```
@@ -494,7 +513,6 @@ will be draggable, even if the item is marked `static: true`.
494
513
495
514
` < ReactGridLayout> ` has [an optimized ` shouldComponentUpdate` implementation](lib/ReactGridLayout.jsx), but it relies on the user memoizing the ` children` array:
496
515
497
-
498
516
` ` ` js
499
517
// lib/ReactGridLayout.jsx
500
518
// ...
@@ -517,7 +535,7 @@ If you memoize your children, you can take advantage of this, and reap faster re
517
535
function MyGrid (props ) {
518
536
const children = React .useMemo (() => {
519
537
return new Array (props .count ).fill (undefined ).map ((val , idx ) => {
520
- return < div key= {idx} data- grid= {{x: idx, y: 1 , w: 1 , h: 1 }} / > ;
538
+ return < div key= {idx} data- grid= {{ x: idx, y: 1 , w: 1 , h: 1 }} / > ;
521
539
});
522
540
}, [props .count ]);
523
541
return < ReactGridLayout cols= {12 }> {children}< / ReactGridLayout> ;
@@ -540,7 +558,7 @@ const CustomGridItemComponent = React.forwardRef(({style, className, ...props},
540
558
return (
541
559
< div style= {{ /* styles */ , ... style}} className= {className} ref= {ref}>
542
560
{/* Some other content */ }
543
- < / div>
561
+ < / div>
544
562
);
545
563
}
546
564
` ` `
0 commit comments