Skip to content

Commit cbcc8cd

Browse files
author
Brian Vaughn
committed
Added ScrollSync test harness
1 parent 6434ad0 commit cbcc8cd

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

playground/scroll-sync.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>foo</title>
6+
<style type="text/css">
7+
body, html, #mount {
8+
width: 100%;
9+
height: 100%;
10+
margin: 0;
11+
padding: 0;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<div id="mount"></div>
17+
18+
<script src="utils.js"></script>
19+
<script src="helper.js"></script>
20+
<script>
21+
loadReact();
22+
loadScriptsAndStyles('scroll-sync.js');
23+
</script>
24+
</body>
25+
</html>

playground/scroll-sync.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
function cellRenderer (params) {
2+
return React.createElement(
3+
'div',
4+
{
5+
className: 'item',
6+
key: params.key,
7+
style: params.style
8+
},
9+
params.columnIndex
10+
)
11+
}
12+
13+
var App = React.createClass({
14+
render: function() {
15+
return React.createElement(
16+
ReactVirtualized.AutoSizer,
17+
null,
18+
function (autoSizerParams) {
19+
return React.createElement(
20+
ReactVirtualized.ScrollSync,
21+
null,
22+
function (scrollSyncParams) {
23+
return React.createElement(
24+
'div',
25+
{
26+
style: {
27+
height: autoSizerParams.height,
28+
width: autoSizerParams.width
29+
}
30+
},
31+
React.createElement(
32+
ReactVirtualized.Grid,
33+
{
34+
cellRenderer: cellRenderer,
35+
columnCount: 1000,
36+
columnWidth: 35,
37+
height: autoSizerParams.height / 2,
38+
key: 0,
39+
overscanRowCount: 0,
40+
rowHeight: 30,
41+
rowCount: 5000,
42+
scrollLeft: scrollSyncParams.scrollLeft,
43+
width: autoSizerParams.width
44+
}
45+
),
46+
React.createElement(
47+
ReactVirtualized.Grid,
48+
{
49+
cellRenderer: cellRenderer,
50+
columnCount: 1000,
51+
columnWidth: 35,
52+
height: autoSizerParams.height / 2,
53+
key: 1,
54+
overscanRowCount: 0,
55+
onScroll: scrollSyncParams.onScroll,
56+
rowHeight: 30,
57+
rowCount: 5000,
58+
width: autoSizerParams.width
59+
}
60+
)
61+
)
62+
}
63+
)
64+
}
65+
)
66+
}
67+
})
68+
69+
ReactDOM.render(
70+
React.createElement(App),
71+
document.querySelector('#mount')
72+
)

0 commit comments

Comments
 (0)