Skip to content

Commit dda26d9

Browse files
committed
Mobile wide screen fixed
1 parent 35dbee6 commit dda26d9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

frontend/src/components/clock/ClockGrid.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function ClockGrid(props) {
1313

1414
const { currentTimeZoneId } = useTimeZones();
1515
const { handleError } = useErrorContext();
16-
const { isTablet, isMobile } = useDeviceContext();
16+
const { isTablet, isMobile, isSmallHorizontal } = useDeviceContext();
1717

1818
const [gridRows, setGridRows] = useState(rows);
1919
const [gridCols, setGridCols] = useState(cols * 6);
@@ -26,7 +26,7 @@ function ClockGrid(props) {
2626
const previousHourArrowDegreesArray = useRef("");
2727

2828
useEffect(() => {
29-
if(isTablet) {
29+
if(isTablet || isSmallHorizontal) {
3030
setGridSize(2)
3131
} else {
3232
if(isSecondsEnabled && isSeparatorsEnabled) {
@@ -41,6 +41,8 @@ function ClockGrid(props) {
4141
}, [isSecondsEnabled, isSeparatorsEnabled, isMobile, isTablet]);
4242

4343
useEffect(() => {
44+
console.log("isMobile: ", isMobile + ", isTablet: " + isTablet);
45+
4446
if (!currentTimeZoneId) {
4547
//console.warn("Timezone is not defined, waiting...");
4648
return;

frontend/src/components/contexts/DeviceContext.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import {createContext, useContext, useEffect, useState} from "react";
33
const DeviceContext = createContext();
44

55
export function DeviceProvider({ children }) {
6+
const [isSmallHorizontal, setIsSmallHorizontal] = useState(window.innerHeight <= 480);
67
const [isMobile, setIsMobile] = useState(window.innerWidth <= 768);
7-
const [isTablet, setIsTablet] = useState(window.innerWidth <= 1024);
8+
const [isTablet, setIsTablet] = useState(window.innerWidth <= 1024 && window.innerHeight > 480);
89

910
useEffect(() => {
1011
function handleResize() {
11-
setIsMobile(window.innerWidth <= 768 || window.innerHeight <= 768);
12-
setIsTablet(window.innerWidth <= 1024);
12+
setIsSmallHorizontal(window.innerHeight <= 480);
13+
setIsMobile(window.innerWidth <= 768);
14+
setIsTablet(window.innerWidth <= 1024 && window.innerHeight > 480);
1315
}
1416

1517
window.addEventListener('resize', handleResize);
@@ -20,6 +22,7 @@ export function DeviceProvider({ children }) {
2022
<DeviceContext.Provider value={{
2123
isMobile,
2224
isTablet,
25+
isSmallHorizontal
2326
}}>
2427
{children}
2528
</DeviceContext.Provider>

0 commit comments

Comments
 (0)