forked from pomber/git-history
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
207 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- move diffing to web worker | ||
- make diffing incremental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
|
||
export default function useChildren({ | ||
items, | ||
getRow, | ||
getRowHeight, | ||
height, | ||
top, | ||
data | ||
}) { | ||
const children = []; | ||
|
||
const extraRender = 200; | ||
|
||
const topT = top - extraRender; | ||
const bottomT = top + height + extraRender; | ||
let h = 0; | ||
|
||
let topPlaceHolderH = 0; | ||
let bottomPlaceholderH = 0; | ||
|
||
// This is the bottleneck | ||
items.forEach((item, i) => { | ||
const itemH = getRowHeight(item, i, data); | ||
const nextH = h + itemH; | ||
const isOverTop = nextH < topT; | ||
const isUnderBottom = h > bottomT; | ||
|
||
if (isOverTop) { | ||
topPlaceHolderH += itemH; | ||
} else if (isUnderBottom) { | ||
bottomPlaceholderH += itemH; | ||
} else { | ||
children.push(getRow(item, i, data)); | ||
} | ||
|
||
h = nextH; | ||
}); | ||
|
||
children.unshift(<div style={{ height: topPlaceHolderH }} key="top-ph" />); | ||
children.push(<div style={{ height: bottomPlaceholderH }} key="bottom-ph" />); | ||
return children; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters