-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* カードのスクロールをとりやめ * クリック時にカードが少し小さくなる(UX改善) * モバイルかつ横画面の時に警告(応急処置)
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useCallback, useEffect, useState } from "react"; | ||
|
||
const BanLandscape = () => { | ||
const [isLandscape, setIsLandscape] = useState(false); | ||
|
||
const checkOrientation = useCallback(() => { | ||
const userAgent = navigator.userAgent; | ||
const isMobile = /iPhone|Android|Mobile/i.test(userAgent); | ||
if (isMobile) { | ||
setIsLandscape(window.innerHeight < window.innerWidth); | ||
} else { | ||
setIsLandscape(false); // モバイルデバイスでない場合は常に縦画面扱い | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
checkOrientation(); | ||
window.addEventListener("resize", checkOrientation); | ||
return () => { | ||
window.removeEventListener("resize", checkOrientation); | ||
}; | ||
}, [checkOrientation]); | ||
|
||
return ( | ||
<div style={{ position: "relative", width: "100%", height: "100%" }}> | ||
{isLandscape && ( | ||
<div | ||
style={{ | ||
position: "fixed", | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
backgroundColor: "rgba(0, 0, 0, 0.7)", | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
zIndex: 1000, | ||
}} | ||
> | ||
<div | ||
style={{ | ||
backgroundColor: "white", | ||
padding: "20px", | ||
borderRadius: "10px", | ||
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.5)", | ||
textAlign: "center", | ||
fontSize: "20px", | ||
color: "#333", | ||
}} | ||
> | ||
このアプリは縦画面で使用してください | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BanLandscape; |
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