-
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.
feat: support offset when nav back to home screen
- Loading branch information
Yaron Galperin
committed
Feb 6, 2023
1 parent
c7ed078
commit c09dec0
Showing
3 changed files
with
67 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useState, createContext } from 'react' | ||
|
||
interface IScrollContext { | ||
offsetY: number | ||
updateOffsetY: (offset: number) => void | ||
} | ||
|
||
const INITIAL_STATE: IScrollContext = { | ||
offsetY: 0, | ||
updateOffsetY: (offset: number) => {offset} | ||
} | ||
|
||
export const ScrollContext = createContext(INITIAL_STATE) | ||
|
||
export const ScrollContextProvider = ({ children }: {children: React.ReactNode}) => { | ||
const [offsetY, setOffsetY] = useState<number>(0) | ||
|
||
const updateOffsetY = (offset: number) => { | ||
setOffsetY(offset) | ||
} | ||
|
||
return ( | ||
<ScrollContext.Provider value={{ offsetY, updateOffsetY }}> | ||
{children} | ||
</ScrollContext.Provider>) | ||
} |
c09dec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pokemon – ./
pokemon-git-main-yaronglp.vercel.app
pokemon-yaronglp.vercel.app
pokemon-one-puce.vercel.app
c09dec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pokemon-kde6 – ./
pokemon-kde6.vercel.app
pokemon-kde6-yaronglp.vercel.app
pokemon-kde6-git-main-yaronglp.vercel.app