Skip to content

Commit 6aefc0f

Browse files
committed
Merge pull request #153 from bvaughn/performance-tweaking
Performance tweaking
2 parents e1d18d8 + 948e3a1 commit 6aefc0f

5 files changed

Lines changed: 19 additions & 26 deletions

File tree

playground/grid.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
box-sizing: border-box;
1818
}
1919
</style>
20-
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.min.js"></script>
21-
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.min.js"></script>
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
2222
<script src="../dist/umd/react-virtualized.js"></script>
2323
</head>
2424
<body>

playground/grid.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
11
function renderCell (params) {
2-
// return React.DOM.span(null, `column:${params.columnIndex}, row:${params.rowIndex}`)
32
return React.DOM.input({
43
className: 'input',
54
onChange: function () {},
65
defaultValue: `column:${params.columnIndex}, row:${params.rowIndex}`
76
})
87
}
98

10-
/*
11-
function measurePerformance () {
12-
console.log('measurePerformance()')
13-
var measurements = React.addons.Perf.getLastMeasurements()
14-
if (measurements.length > 0) {
15-
console.group('printDOM')
16-
React.addons.Perf.printDOM(measurements)
17-
console.groupEnd()
18-
19-
console.group('printWasted')
20-
React.addons.Perf.printWasted(measurements)
21-
console.groupEnd()
22-
23-
React.addons.Perf.start()
24-
}
25-
}
26-
*/
27-
289
var App = React.createClass({
29-
componentDidMount: function () {
30-
// React.addons.Perf.start()
31-
// window.Perf = React.addons.Perf
32-
},
33-
3410
render: function() {
3511
return React.createElement(
3612
ReactVirtualized.AutoSizer,

source/AutoSizer/AutoSizer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default class AutoSizer extends Component {
4141
}
4242

4343
this._onResize = this._onResize.bind(this)
44+
this._onScroll = this._onScroll.bind(this)
4445
this._setRef = this._setRef.bind(this)
4546
}
4647

@@ -77,6 +78,7 @@ export default class AutoSizer extends Component {
7778
return (
7879
<div
7980
ref={this._setRef}
81+
onScroll={this._onScroll}
8082
style={outerStyle}
8183
>
8284
{children({ height, width })}
@@ -102,6 +104,11 @@ export default class AutoSizer extends Component {
102104
onResize({ height, width })
103105
}
104106

107+
_onScroll (event) {
108+
// Prevent detectElementResize library from being triggered by this scroll event.
109+
event.stopPropagation()
110+
}
111+
105112
_setRef (autoSizer) {
106113
// In case the component has been unmounted
107114
this._parentNode = autoSizer && autoSizer.parentNode

source/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
overflow: auto;
66
outline: 0;
77
-webkit-overflow-scrolling: touch;
8+
9+
/* Without this property, Chrome repaints the entire Grid any time a new row or column is added.
10+
Firefox only repaints the new row or column (regardless of this property).
11+
Safari and IE don't support the property at all. */
12+
will-change: transform;
813
}
914

1015
.Grid__innerScrollContainer {

styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
overflow: auto;
66
outline: 0;
77
-webkit-overflow-scrolling: touch;
8+
9+
/* Without this property, Chrome repaints the entire Grid any time a new row or column is added.
10+
Firefox only repaints the new row or column (regardless of this property).
11+
Safari and IE don't support the property at all. */
12+
will-change: transform;
813
}
914

1015
.Grid__innerScrollContainer {

0 commit comments

Comments
 (0)