ð£prefers-reduced-motionã¡ãã£ã¢ã¯ãšãªã§ã¢ãã¡ãŒã·ã§ã³é ãã«é æ ®ãã
è¿å¹ŽãCSSâãâJavaScriptâã®é²åã«ããããã©ã©ãã¯ã¹ãã¹ã¯ããŒã«ãšãšãã«ã¢ãã¡ãŒã·ã§ã³ããªããç»å Žãããšãã§ã¯ããªã©ãæŒåºã®ããã®ã¢ãã¡ãŒã·ã§ã³ãããªãå¢ããŸããã
Webâãµã€ãã«ç¬èªæ§ãåºãããšãã§ããŠéå®ãããäžæ¹ã§ãé床ãªã¢ãã¡ãŒã·ã§ã³ã«ããç»é¢é ãã蚎ãã人ãåºãŠããŠããŸãã
ããã§ãCSS Media Queries Level 5âã§ã¯ãprefers-reduced-motionâç¹æ§ãææ¡ãããŠããŸãã
é床ãªã¢ãã¡ãŒã·ã§ã³ãšã¯
ã¢ãã¡ãŒã·ã§ã³ã«ã¯æ¬æ¥ãããŒãç»é¢ãã¹ã±ã«ãã³ã¹ã¯ãªãŒã³ãªã©ããŠãŒã¶ãŒã«çŸåšã®é²è¡ç¶æ³ãäŒãããšãã倧äºãªåœ¹ç®ããããŸãã
ããã§ããé床ãªã¢ãã¡ãŒã·ã§ã³ãšã¯ãèæ¯ã®ã¢ãã¡ãŒã·ã§ã³ãç»é¢å šäœã«åºããèæ¯åç»ããã©ã©ãã¯ã¹ãšãã§ã¯ããç»é¢é·ç§»ãªã©ã®æ¬è³ªçã§ãªãã¢ãã¡ãŒã·ã§ã³ã®ããšã§ãã
ãã©ã©ãã¯ã¹ãšãã§ã¯ãã®ããã«ãèé¢ãšåé¢ã§ã¹ã¯ããŒã«ã®ã¹ããŒããéãããšã§ãç»é¢é ããèµ·ããå ŽåããããŸãã
ãããŸã§ãprefers-reduced-motionâã§ãã£ãŠâprefers-no-motionâã§ã¯ãªãããããã¹ãŠã®ã¢ãã¡ãŒã·ã§ã³ããªããããã§ã¯ãããŸããã
ããã€ã¹ã®èšå®
ããããprefers-reduced-motionâç¹æ§ãå®è£ ãããããšã§ããã¹ãŠè§£æ±ºãšããããã«ã¯ãããªãããã§ãã
ããã€ã¹ã®ã©ã®èšå®é ç®ã«ãã£ãŠâprefers-reduced-motionâç¹æ§ãå€å®ããããããã£ããç解ããŠããå¿ èŠããããŸããããã¯ãéçºè ã ãã§ãªããå®éã«äœ¿ããŠãŒã¶ãŒãèªèããŠãããæ¹ããããšæããŸãã
Windowsâã®èšå®
Windowsâã«ã¯ãprefers-reduced-motionâç¹æ§ã«é¢ããèšå®ãè€æ°ç®æã«ååšããŸãã
ãŸãââ1âã€ç®ã¯ã[èšå®]â>â[ç°¡åæäœ]â>â[ãã£ã¹ãã¬ã€]â>â[Windowsâã«ã¢ãã¡ãŒã·ã§ã³ã衚瀺ãã]âã®ãã°ã«ã§ãã
2âã€ç®ã¯ã[ã³ã³ãããŒã«ããã«]â>â[ã·ã¹ãã ãšã»ãã¥ãªãã£]â>â[ã·ã¹ãã ]â>â[ã·ã¹ãã ã®è©³çŽ°èšå®]â>â[ããã©ãŒãã³ã¹èšå®]â>â[èŠèŠå¹æ]âã«ããâ[Windowsâå ã®ã¢ãã¡ãŒã·ã§ã³ã³ã³ãããŒã«ãšèŠçŽ ]âãšãããã§ãã¯ããã¯ã¹ã§ãã
ãããŠâ3âã€ç®ã¯ã[ã³ã³ãããŒã«ããã«]â>â[ã³ã³ãã¥ãŒã¿ãŒã®ç°¡åæäœ]â>â[ã³ã³ãã¥ãŒã¿ãŒã®ç°¡åæäœã»ã³ã¿ãŒ]â>â[ã³ã³ãã¥ãŒã¿ãŒãèŠãããããŸã]âã«ããâ[å¿ èŠã®ãªãã¢ãã¡ãŒã·ã§ã³ã¯ç¡å¹ã«ããŸã(å¯èœãªå Žå)]âãšãããã§ãã¯ããã¯ã¹ã§ãã
ããã§æ³šæãããã®ãã3âã€ã®èšå®ã®ãã¡â2âã€ç®ã®ããã©ãŒãã³ã¹èšå®ã«é¢ããŠã¯ã¢ã¯ã»ã·ããªãã£ã®èšå®ã§ã¯ãªããåã«âWindowsâã®åäœã軜ãããããã«äœåãªã¢ãã¡ãŒã·ã§ã³ãç¡å¹ã«ããã人ãèšå®ãããã®ã ãšããããšã§ãã
ãããšãWindowsâåŽã®ã¢ãã¡ãŒã·ã§ã³ã ããç¡å¹ã«ããã€ãããããã©ãŠã¶äžã®ã¢ãã¡ãŒã·ã§ã³ãŸã§ç¡å¹ã«ãããŠããŸããšããåé¡ãèµ·ããŸãã
WindowsâåŽã®ã¢ãã¡ãŒã·ã§ã³ã¯ç¡å¹ã«ãã€ã€ããã©ãŠã¶äžã®ã¢ãã¡ãŒã·ã§ã³ã¯æå¹ã«ãããå Žåã¯ã[Windowsâå ã®ã¢ãã¡ãŒã·ã§ã³ã³ã³ãããŒã«ãšèŠçŽ ]âãã§ãã¯ããã¯ã¹ã¯ãã§ãã¯ãå ¥ãããŸãŸããã®ä»ã®é ç®ãåå¥ã«ãªãã«ããŠããå¿ èŠããããŸãã
çŸåšã®ç¶æ³ã§ã¯ãã¢ã¯ã»ã·ããªãã£ãšããã©ãŒãã³ã¹ã®2ã€ã®èŠ³ç¹ããã¢ãã¡ãŒã·ã§ã³ã®å¶åŸ¡ãè¡ãããšãã§ãããããæ··ä¹±ãæãæãããããšæãããŸãã
MacOSâã®èšå®
[ã·ã¹ãã ç°å¢èšå®]â>â[ã¢ã¯ã»ã·ããªãã£]â>â[ãã£ã¹ãã¬ã€]â>â[èŠå·®å¹æãæžãã]âãšãããã§ãã¯ããã¯ã¹ã§èšå®ããŸãã
iOSâã®èšå®
[èšå®]â>â[ã¢ã¯ã»ã·ããªãã£]â>â[åäœ]â>â[èŠå·®å¹æãæžãã]âãšãããã°ã«ã§èšå®ããŸãã
Androidâã®èšå®
[èšå®]â>â[ãŠãŒã¶ãŒè£å©]â>â[èŠèªæ§åäž]â>â[ã¢ãã¡ãŒã·ã§ã³ãåé€]âãšãããã°ã«ã§èšå®ããŸãã
ãã®ããã«ãåããã€ã¹ã§èšå®ã§ããããã«ãªã£ãŠããŸãã
ã¡ãã£ã¢ã¯ãšãªã®æžãæ¹
ããŠãã©ã®èšå®ãâprefers-reduced-motionâç¹æ§ã«åœ±é¿ãåãŒããç解ãããšããã§ãå®éã«ã¡ãã£ã¢ã¯ãšãªãæžããŠã¿ãŸãã
èŠå·®å¹æãæžããããã«èšå®ãããŠãããšãã«âtransitionâãâanimationâãç¡å¹ã«ããã°ããã®ã§ã以äžã®ããã«ãªããŸãã
@media (prefers-reduced-motion: reduce) {
*,
::before,
::after {
transition: none !important;
animation: none !important;
}
}
ãããããã®æžãæ¹ã«ã¯â2âã€ã®åé¡ç¹ããããŸãã
ããšãã°ãopacityâããããã£ã®å€ãâ0âããâ1âã«å€ããã¢ãã¡ãŒã·ã§ã³ã®å Žåãanimation: none !important;âãšããŠããŸããšãèŠçŽ ããã£ãšè¡šç€ºãããªããŸãŸã«ãªã£ãŠããŸããŸãã
ãããŠããâ1âã€ãtransitionendâãâanimationendâã€ãã³ããçºç«ããªãåé¡ãçºçããŸããã¢ãã¡ãŒã·ã§ã³ãçµäºãããšãã«âJavaScriptâã§äœããã®åŠçãè¡ãå Žåãã€ãã³ããçºç«ããªãããåŠçãè¡ãããªããŸãŸãšãªã£ãŠããŸããŸãã
ããã§ã次ã®ããã«æå®ããŸãã
@media (prefers-reduced-motion: reduce) {
*,
::before,
::after {
animation-delay: -1ms !important;
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
transition-delay: 0s !important;
transition-duration: 1ms !important;
}
}
animation-durationâããããã£ã«â1msâãšããéåžžã«çãæéãæå®ããããšã§ãã¢ãã¡ãŒã·ã§ã³ã¯å®è¡ãããããåé¡ç¹ã¯è§£æ¶ãããŸãã
animation-delayâããããã£ã«â-1msâãæå®ããŠããã®ã¯ãè² ã®å€ãæå®ããããšã§â1msâåŸã®ç¶æ³ããã¢ãã¡ãŒã·ã§ã³ãéå§ãããå®è³ªã¢ãã¡ãŒã·ã§ã³ã®æç»ããªããããã§ãã
ãŸããanimation-iteration-countâããããã£ã«â1âãæå®ããããšã§ãç¡éã«åçãããâinfiniteâã¢ãã¡ãŒã·ã§ã³ãâ1â床ã ãåçãããããã«ããŸãã
transitionâããããã£ãâanimationâãšåæ§ã«æå®ããŸãããtransition-delayâããããã£ã«â-1msâãæå®ãããšâChromeâã§âtransitionendâã€ãã³ããçºç«ããªããšããåé¡ãããããã0sâãšããŠããŸãã
transition-durationâããããã£ã«â0sâãæå®ããŠããäŸãèŠãããŸãããSafariâã§âtransitionendâã€ãã³ããçºç«ããªããªãã®ã§ã1msâãšããŠããŸãã
@media (prefers-reduced-motion: reduce) {
*,
::before,
::after {
animation-delay: -1ms !important;
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
transition-delay: 0s !important;
transition-duration: 1ms !important;
background-attachment: initial !important;
scroll-behavior: auto !important;
}
}
ã€ãã§ã«ãbackground-attachmentâãšâscroll-behaviorâããããã£ãç¡å¹ã«ããŠãããšãããããããŸãããã
@media (prefers-reduced-motion: reduce) {
:not(.safe-animation),
:not(.safe-animation)::before,
:not(.safe-animation)::after {
animation-delay: -1ms !important;
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
transition-delay: 0s !important;
transition-duration: 1ms !important;
background-attachment: initial !important;
scroll-behavior: auto !important;
}
}
ãŸããäžéšã®èŠçŽ ã«ã®ã¿æå®ããããšãã¯â:not(.safe-animation)âãšããããã«ããã°ã.safe-animationâã¯ã©ã¹ãæå®ãããŠããèŠçŽ ã¯é€å€ã§ããŸãã
察å¿ãã©ãŠã¶
ã»IE -
ã»Edge -
ã»Chromium Edge 79
ã»Firefox 63
ã»Chrome 74
ã»Safari 10.1
ã»Opera 62
ã»iOS Safari 10.3
ã»Android 79
ãã§ã«ãã»ãŒãã¹ãŠã®ãã©ãŠã¶ã察å¿ããŠããã®ã§ãä»ãã察å¿ããŠãããšãããšæããŸãã