-
Notifications
You must be signed in to change notification settings - Fork 7
Split scroll context #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Split scroll context #467
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3708513
move useFetchCells to ScrollProvider
severo 7a7aae2
remove obsolete field
severo a385b63
be explicit about the fields
severo 7230f10
split ScrollContext
severo 60667bb
remove useMemo where it's not needed
severo 4a7c73a
fix condition
severo ee63df4
fix type
severo cb82f53
add intermediate Slice component and rename Slice to Table
severo c2009b5
rename
severo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,32 +1,28 @@ | ||
| import { createContext } from 'react' | ||
|
|
||
| export interface ScrollContextType { | ||
| /** Total scrollable height, in pixels */ | ||
| canvasHeight?: number | ||
| /** Offset of the top of the visible slice from the top of the canvas, in pixels */ | ||
| sliceTop?: number | ||
| /** Index of the first row visible in the viewport (inclusive). Indexes refer to the virtual table domain. */ | ||
| visibleRowsStart?: number | ||
| /** Index of the last row visible in the viewport (exclusive). */ | ||
| visibleRowsEnd?: number | ||
| /** | ||
| * Function to call when the current scroll top position changes (on scroll) | ||
| * | ||
| * @param scrollTop The new scroll top position in pixels | ||
| */ | ||
| export const SetScrollTopContext = createContext<((scrollTop: number) => void) | undefined>(undefined) | ||
|
|
||
| /** | ||
| * Function to set the scrollTo function | ||
| * | ||
| * @param scrollTo The scrollTo function of the viewport element (on component mount), or undefined (on unmount) | ||
| */ | ||
| export const SetScrollToContext = createContext<((scrollTo: HTMLElement['scrollTo'] | undefined) => void) | undefined>(undefined) | ||
|
|
||
| /** Total scrollable height, in pixels */ | ||
| export const CanvasHeightContext = createContext<number | undefined>(undefined) | ||
|
|
||
| /** Offset of the top of the visible slice from the top of the canvas, in pixels */ | ||
| export const SliceTopContext = createContext<number | undefined>(undefined) | ||
|
|
||
| export const RenderedRowsContext = createContext<{ | ||
| /** Index of the first row rendered in the DOM as a table row (inclusive). */ | ||
| renderedRowsStart?: number | ||
| /** Index of the last row rendered in the DOM as a table row (exclusive). */ | ||
| renderedRowsEnd?: number | ||
| /** | ||
| * Function to set the scrollTo function | ||
| * | ||
| * @param scrollTo The scrollTo function of the viewport element (on component mount), or undefined (on unmount) | ||
| */ | ||
| setScrollTo?: (scrollTo: HTMLElement['scrollTo'] | undefined) => void | ||
| /** | ||
| * Function to call when the current scroll top position changes (on scroll) | ||
| * | ||
| * @param scrollTop The new scroll top position in pixels | ||
| */ | ||
| setScrollTop?: (scrollTop: number) => void | ||
| } | ||
|
|
||
| export const defaultScrollContext: ScrollContextType = {} | ||
|
|
||
| export const ScrollContext = createContext<ScrollContextType>(defaultScrollContext) | ||
| }>({}) | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.