forked from andychase/gbajs2
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: make canvas fade generic regardless of aspect ratio * fix: gbc screen resolution shift when run - initial pass at fixing gbc screen resoution shifts - emulator controls canvas, let it dictate the canvas resolution and height - bump wasm files * refactor: rename to fade.ts * feat: contain different screen resolutions - tentative attempt at containing different screen resolutions in the screenwrapper - avoids layout jerk - todo: refactor to scale canvas on resize * refactor: extract layout to a hook * refactor: use css to maintain canvas aspect ratio - use object fit contain to keep the canvas aspect ratio contained regardless of the parent aspect ratio - remove unnecessary code * feat: ensure wasm files are current --------- Co-authored-by: Nick VanCise
- Loading branch information
1 parent
1eb92e5
commit 3e24bec
Showing
10 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,33 @@ | ||
import { useLocalStorage } from '@uidotdev/usehooks'; | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
type Layout = { | ||
position?: { x: number; y: number }; | ||
size?: { width: string | number; height: string | number }; | ||
initialBounds?: DOMRect; | ||
}; | ||
|
||
type Layouts = { | ||
[key: string]: Layout; | ||
}; | ||
|
||
const layoutLocalStorageKey = 'componentLayouts'; | ||
|
||
export const useLayouts = () => { | ||
const [layouts, setLayouts] = useLocalStorage<Layouts>( | ||
layoutLocalStorageKey, | ||
{} | ||
); | ||
|
||
const clearLayouts = useCallback(() => setLayouts({}), [setLayouts]); | ||
|
||
const hasSetLayout = useMemo( | ||
() => | ||
!!Object.values(layouts).some( | ||
(layout) => !!layout?.position || !!layout?.size | ||
), | ||
[layouts] | ||
); | ||
|
||
return { layouts, setLayouts, hasSetLayout, clearLayouts }; | ||
}; |
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