Skip to content

Commit ed4fc43

Browse files
author
tsuyoshiwada
committed
Update docs
1 parent c3d9c27 commit ed4fc43

1 file changed

Lines changed: 72 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
Pinterest like layout components for React.js.
88

99

10+
11+
12+
## Table of Contents
13+
14+
* [Live Demo](#live-demo)
15+
* [Install](#install)
16+
* [Quick Example](#quick-example)
17+
* [Props](#props)
18+
* [Instance API](#instance-api)
19+
* [updateLayout(): void](#updatelayout-void)
20+
* [Animations](#animations)
21+
* [Tips](#tips)
22+
* [Performance when using images](#performance-when-using-images)
23+
* [When animation is unnecessary](#when-animation-is-unnecessary)
24+
* [How to manually update layout ?](#how-to-manually-update-layout)
25+
* [Thanks](#thanks)
26+
* [License](#license)
27+
* [ChangeLog](#changelog)
28+
* [Author](#author)
29+
* [Development](#development)
30+
* [Contribution](#contribution)
31+
32+
33+
34+
1035
## Live Demo
1136

1237
![Screenshot](https://raw.githubusercontent.com/tsuyoshiwada/react-stack-grid/images/screenshot.png)
@@ -15,6 +40,7 @@ Pinterest like layout components for React.js.
1540

1641

1742

43+
1844
## Install
1945

2046
You can install the [react-stack-grid](https://www.npmjs.com/package/react-stack-grid) from [npm](https://www.npmjs.com/).
@@ -24,6 +50,8 @@ $ npm install react-stack-grid
2450
```
2551

2652

53+
54+
2755
## Quick Example
2856

2957
Following code is simplest usage.
@@ -50,6 +78,8 @@ class MyComponent extends Component {
5078
width of parent is managed by [react-sizeme](https://github.com/ctrlplusb/react-sizeme).
5179

5280

81+
82+
5383
## Props
5484

5585
You can set the following properties.
@@ -58,6 +88,7 @@ You can set the following properties.
5888
|:----------------------|:------------------------------------------------------------|:---------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------|
5989
| `className` | `PropTypes.string` | `undefined` | Specify `className` of component. |
6090
| `style` | `PropTypes.object` | `{}` | Original style of component. Following styles are ignored. (`position`, `height`, `transition`) |
91+
| `gridRef` | `PropTypes.func` | `null` | Reference the instance of StackGrid. Unlike ordinary `ref`, it accepts only functions. |
6192
| `component` | `PropTypes.string` | `"div"` | See [ReactTransitionGroup](https://facebook.github.io/react/docs/animation.html#rendering-a-different-component) |
6293
| `columnWidth` | `PropTypes.oneOfType([PropTypes.number, PropTypes.string])` | `150` | Specify column width as an number(`px`), or percentage string. (Example `"33.33%"`) |
6394
| `gutterWidth` | `PropTypes.number` | `5` | Specify gutter width as an number. |
@@ -78,6 +109,16 @@ You can set the following properties.
78109

79110

80111

112+
113+
## Instance API
114+
115+
### updateLayout(): void
116+
117+
Update the current layout.
118+
119+
120+
121+
81122
## Animations
82123

83124
The following function must return styles related to animation.
@@ -138,7 +179,6 @@ Please try actual demonstration in [live demo](https://tsuyoshiwada.github.io/re
138179

139180

140181

141-
142182
## Tips
143183

144184

@@ -163,6 +203,32 @@ If it's not necessary, specify `0` for `duration` property.
163203
```
164204

165205

206+
### How to manually update layout ?
207+
208+
If the size of an item is changed by an action such as a click event, there are cases where you want to update the layout manually.
209+
You can manually update the layout by referring to the StackGrid instance with `gridRef` and executing the`updateLayout()` method.
210+
211+
```javascript
212+
class MyComponent extends React.Component {
213+
214+
// When the size of the item is changed...
215+
something = () => {
216+
this.grid.updateLayout();
217+
};
218+
219+
render() {
220+
return (
221+
<StackGrid
222+
gridRef={grid => this.grid = grid}
223+
>
224+
{/* items ... */}
225+
</StackGrid>
226+
);
227+
}
228+
}
229+
```
230+
231+
166232

167233

168234
## Thanks
@@ -172,24 +238,28 @@ If it's not necessary, specify `0` for `duration` property.
172238

173239

174240

241+
175242
## License
176243

177244
Released under the [MIT Licence](https://raw.githubusercontent.com/tsuyoshiwada/react-stack-grid/master/LICENSE)
178245

179246

180247

248+
181249
## ChangeLog
182250

183251
See [CHANGELOG.md](./CHANGELOG.md)
184252

185253

186254

255+
187256
## Author
188257

189258
[tsuyoshiwada](https://github.com/tsuyoshiwada)
190259

191260

192261

262+
193263
## Development
194264

195265
Initialization of the project.
@@ -224,6 +294,7 @@ $ npm run build
224294
```
225295

226296

297+
227298
## Contribution
228299

229300
Thank you for your interest in react-stack-grid.js.

0 commit comments

Comments
 (0)