Screen: orientation ããããã£
Baseline
åºãå©ç¨å¯è½
ãã®æ©è½ã¯åºãå®è£ ããã¦ãããå¤ãã®ãã¼ã¸ã§ã³ã®ç«¯æ«ããã©ã¦ã¶ã¼ã§åä½ãã¾ãã2023å¹´3æä»¥éããã¹ã¦ã®ãã©ã¦ã¶ã¼ã§å©ç¨å¯è½ã§ãã
orientation 㯠Screen ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®èªã¿åãå°ç¨ããããã£ã§ãç¾å¨ã®ç»é¢ã®åããè¿ãã¾ãã
å¤
ç»é¢ã®åãã表ã ScreenOrientation ã®ã¤ã³ã¹ã¿ã³ã¹ã§ãã
ãªããå¤ãæ¥é è¾ä»ãã®ãã®ã¯æååã§ ScreenOrientation.type ã¨åçã®ãã®ãè¿ãã¦ãã¾ããã
ä¾
js
switch (screen.orientation.type) {
case "landscape-primary":
console.log("è¯ãæãã§ããã");
break;
case "landscape-secondary":
console.log("ãã¼ãâ¦ãç»é¢ãä¸ä¸éã§ãï¼");
break;
case "portrait-secondary":
case "portrait-primary":
console.log("ãã¼ãâ¦ãã¹ã¯ãªã¼ã³ã横åãã«ããæ¹ãããã§ãã");
break;
default:
console.log("ãã®ãã©ã¦ã¶ã¼ã¯ç»é¢æ¹å API ã«å¯¾å¿ãã¦ãã¾ãã :(");
}
仿§æ¸
| 仿§æ¸ |
|---|
| Screen Orientation > # dom-screen-orientation > |
ãã©ã¦ã¶ã¼ã®äºææ§
é¢é£æ å ±
ScreenOrientationorientationchangeã¤ãã³ã- ç»é¢ã®åãã®å¶å¾¡