Skip to content

Commit

Permalink
test: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thenick775 committed Dec 16, 2024
1 parent 7d2db54 commit 9c16c67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gbajs3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" href="/img/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, shrink-to-fit=no"
/>
<meta
name="description"
Expand Down
13 changes: 12 additions & 1 deletion gbajs3/src/components/screen/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const Screen = () => {
const { setCanvas } = useEmulatorContext();
const { areItemsDraggable } = useDragContext();
const { areItemsResizable } = useResizeContext();
const { layouts, setLayout, hasSetLayout } = useLayoutContext();
const { layouts, setLayout, hasSetLayout, clearLayouts } = useLayoutContext();
const screenWrapperXStart = isLargerThanPhone ? NavigationMenuWidth + 10 : 0;
const screenWrapperYStart = isLargerThanPhone && !isMobileLandscape ? 15 : 0;
const rndRef = useRef<Rnd | null>();
Expand All @@ -89,15 +89,26 @@ export const Screen = () => {
useLayoutEffect(() => {
if (layouts?.screen?.position || layouts?.screen?.size) return;

console.log(
'window/screen',
window.innerWidth,
window.innerHeight,
screen.width,
screen.height
);

const x = Math.floor(
window.innerWidth / 2 - (layouts?.screen?.initialBounds?.width ?? 0) / 2
);
const y = Math.floor(
window.innerHeight / 2 - (layouts?.screen?.initialBounds?.height ?? 0) / 2
);

console.log('x/y/isMobileLandscape', x, y, isMobileLandscape);

if (isMobileLandscape) rndRef?.current?.updatePosition({ x, y });

clearLayouts();
setLayout('screen', {
initialBounds:
rndRef.current?.resizableElement?.current?.getBoundingClientRect()
Expand Down

0 comments on commit 9c16c67

Please sign in to comment.