Tina Tarighian
commited on
Commit
·
c5e133c
1
Parent(s):
1d3a8d7
shrink mobile canvas
Browse files- components/MainContent.js +4 -1
- hooks/useDeviceAndCanvas.js +4 -2
components/MainContent.js
CHANGED
@@ -63,7 +63,10 @@ const MainContent = ({
|
|
63 |
<canvas
|
64 |
ref={canvasRef}
|
65 |
className="rounded-lg shadow-lg w-full"
|
66 |
-
style={{
|
|
|
|
|
|
|
67 |
width={canvasWidth}
|
68 |
height={canvasHeight}
|
69 |
/>
|
|
|
63 |
<canvas
|
64 |
ref={canvasRef}
|
65 |
className="rounded-lg shadow-lg w-full"
|
66 |
+
style={{
|
67 |
+
height: `${canvasHeight}px`,
|
68 |
+
...(isMobile && { margin: '0 auto', display: 'block' })
|
69 |
+
}}
|
70 |
width={canvasWidth}
|
71 |
height={canvasHeight}
|
72 |
/>
|
hooks/useDeviceAndCanvas.js
CHANGED
@@ -45,9 +45,11 @@ const useDeviceAndCanvas = () => {
|
|
45 |
const containerWidth = document.querySelector('.canvas-container')?.clientWidth || window.innerWidth;
|
46 |
// Set maximum width for the canvas - increased for desktop
|
47 |
const maxWidth = Math.min(containerWidth, isMobile ? 640 : 960);
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
setCanvasWidth(
|
51 |
setCanvasHeight(height);
|
52 |
}, [isMobile]);
|
53 |
|
|
|
45 |
const containerWidth = document.querySelector('.canvas-container')?.clientWidth || window.innerWidth;
|
46 |
// Set maximum width for the canvas - increased for desktop
|
47 |
const maxWidth = Math.min(containerWidth, isMobile ? 640 : 960);
|
48 |
+
// Apply 0.8 scale factor for mobile devices only
|
49 |
+
const scaledWidth = isMobile ? maxWidth * 0.8 : maxWidth;
|
50 |
+
const height = scaledWidth / aspectRatio;
|
51 |
|
52 |
+
setCanvasWidth(scaledWidth);
|
53 |
setCanvasHeight(height);
|
54 |
}, [isMobile]);
|
55 |
|