Skip to content

Commit 6d084ad

Browse files
committed
Increase offset
1 parent 5c6ddd8 commit 6d084ad

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/scroller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function Scroller({
2929
return (
3030
<div
3131
style={{ height: "100%", overflowY: "auto" }}
32-
class="scroller"
32+
className="scroller"
3333
ref={ref}
3434
onScroll={e => setTop(e.target.scrollTop)}
3535
children={children}

src/slide.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ theme.styles.forEach(({ types, style }) => {
1313
});
1414
});
1515

16-
function Line({ line, style }) {
16+
function getLineHeight(line, i, { styles }) {
17+
return styles[i].height != null ? styles[i].height : 15;
18+
}
19+
20+
function getLine(line, i, { styles }) {
21+
const style = styles[i];
1722
return (
18-
<div style={Object.assign({ overflow: "hidden", height: "15px" }, style)}>
23+
<div
24+
style={Object.assign({ overflow: "hidden", height: "15px" }, style)}
25+
key={line.key}
26+
>
1927
{line.tokens.map((token, i) => {
2028
const style = themeStylesByType[token.type] || {};
2129
return (
@@ -28,14 +36,6 @@ function Line({ line, style }) {
2836
);
2937
}
3038

31-
function getLineHeight(line, i, { styles }) {
32-
return styles[i].height != null ? styles[i].height : 15;
33-
}
34-
35-
function getLine(line, i, { styles }) {
36-
return <Line line={line} style={styles[i]} key={line.key} />;
37-
}
38-
3939
function Slide({ lines, styles }) {
4040
const [top, setTop] = React.useState(0);
4141
return (

src/todo.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
- move diffing to web worker
22
- make diffing incremental
3+
- cache all the react elements from the lines + styles
4+
- only set scrollTop if `top` is different from the last value from the event (and clean the last value from the event after that)

src/use-virtual-children.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function useChildren({
1010
}) {
1111
const children = [];
1212

13-
const extraRender = 500;
13+
const extraRender = 1500;
1414

1515
const topT = top - extraRender;
1616
const bottomT = top + height + extraRender;

0 commit comments

Comments
 (0)