Skip to content

Commit

Permalink
Increase offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Feb 24, 2019
1 parent 5c6ddd8 commit 6d084ad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Scroller({
return (
<div
style={{ height: "100%", overflowY: "auto" }}
class="scroller"
className="scroller"
ref={ref}
onScroll={e => setTop(e.target.scrollTop)}
children={children}
Expand Down
20 changes: 10 additions & 10 deletions src/slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ theme.styles.forEach(({ types, style }) => {
});
});

function Line({ line, style }) {
function getLineHeight(line, i, { styles }) {
return styles[i].height != null ? styles[i].height : 15;
}

function getLine(line, i, { styles }) {
const style = styles[i];
return (
<div style={Object.assign({ overflow: "hidden", height: "15px" }, style)}>
<div
style={Object.assign({ overflow: "hidden", height: "15px" }, style)}
key={line.key}
>
{line.tokens.map((token, i) => {
const style = themeStylesByType[token.type] || {};
return (
Expand All @@ -28,14 +36,6 @@ function Line({ line, style }) {
);
}

function getLineHeight(line, i, { styles }) {
return styles[i].height != null ? styles[i].height : 15;
}

function getLine(line, i, { styles }) {
return <Line line={line} style={styles[i]} key={line.key} />;
}

function Slide({ lines, styles }) {
const [top, setTop] = React.useState(0);
return (
Expand Down
2 changes: 2 additions & 0 deletions src/todo.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- move diffing to web worker
- make diffing incremental
- cache all the react elements from the lines + styles
- only set scrollTop if `top` is different from the last value from the event (and clean the last value from the event after that)
2 changes: 1 addition & 1 deletion src/use-virtual-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useChildren({
}) {
const children = [];

const extraRender = 500;
const extraRender = 1500;

const topT = top - extraRender;
const bottomT = top + height + extraRender;
Expand Down

0 comments on commit 6d084ad

Please sign in to comment.