-
Notifications
You must be signed in to change notification settings - Fork 295
Tweak C39 and add new matching SCR40 #4404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8cbaae6
c54d106
5e2341d
6da6b6f
24a367f
2bcf190
5732592
b9f0275
dd06393
cc80730
316325a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<ol> | ||
<li><time datetime="2025-04-22">2 Jun 2025</time>: Added {{ "G226" | linkTechniques }}</li> | ||
<li><time datetime="2025-05-19">19 May 2025</time>: Added {{ "SCR40" | linkTechniques }}</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<li><time datetime="2025-04-22">22 Apr 2025</time>: Added {{ "F112" | linkTechniques }}</li> | ||
<li><time datetime="2025-04-22">22 Apr 2025</time>: Removed F4 Failure of Success Criterion 2.2.2 due to using text-decoration:blink without a mechanism to stop it in less than five seconds</li> | ||
<li><time datetime="2025-04-22">22 Apr 2025</time>: Removed F47 Failure of Success Criterion 2.2.2 due to using the blink element</li> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | ||
<head> | ||
<title>Using the CSS prefers-reduced-motion query in JavaScript to prevent motion</title> | ||
<link rel="stylesheet" type="text/css" href="../../css/editors.css"/> | ||
</head> | ||
<body> | ||
|
||
<h1>Using the <abbr title="Cascading Style Sheets">CSS</abbr> <code>prefers-reduced-motion</code> query in JavaScript to prevent motion</h1> | ||
|
||
<section id="meta"> | ||
<h2>Metadata</h2> | ||
<p id="id"></p> | ||
<p id="technology"></p> | ||
<p id="type"></p> | ||
</section> | ||
|
||
<section id="applicability"> | ||
<h2>When to Use</h2> | ||
<p> | ||
JavaScript animation which causes motion that is triggered by user interactions. | ||
</p> | ||
</section> | ||
|
||
<section id="description"> | ||
<h2>Description</h2> | ||
<p>The objective of this technique is to allow users to prevent animation from being displayed on web pages, by using JavaScript to evaluate the <code class="language-css">prefers-reduced-motion</code> CSS Media Query.</p> | ||
<p>Some users experience distraction or nausea from animated content. For example, if scrolling a page causes elements to move (other than the essential movement associated with scrolling the content, which is under the user's control) it can trigger vestibular disorders.</p> | ||
<p>Media queries that selectively enable/disable JavaScript-driven animations based on operating system or user agent preferences allow users to prevent those symptoms.</p> | ||
<p>The understanding document for <a href="../../Understanding/animation-from-interactions.html#resources">Animation from Interactions</a> includes links for changing the 'reduced motion' setting.</p> | ||
</section> | ||
|
||
<section id="examples"> | ||
<h2>Examples</h2> | ||
<section class="example"> | ||
<h3>Evaluating the <code>prefers-reduced-motion</code> CSS Media Query in JavaScript</h3> | ||
<p>Users can indicate their motion preference for interfaces in their system. This choice can be detected in JavaScript by evaluating the <code>prefers-reduced-motion</code> CSS Media Query. The script can then decide to enable or disable animation effects based on the result of the media query test.</p> | ||
<pre xml:space="preserve"><code class="language-js">const mediaQueryList = window.matchMedia("(prefers-reduced-motion: no-preference)"); | ||
|
||
if (mediaQueryList.matches) { | ||
/* The user has not expressed a preference for reduced motion – run JavaScript-based animation */ | ||
} | ||
</code></pre> | ||
</section> | ||
</section> | ||
|
||
<section id="tests"> | ||
<h2>Tests</h2> | ||
<section class="test-procedure"> | ||
<h3>Procedure</h3> | ||
<p>For each interactive element that moves due to a user interaction:</p> | ||
<ol> | ||
<li>Enable the reduced motion setting in your system;</li> | ||
<li>Check that the motion is not essential;</li> | ||
<li>Check that the element does not move.</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little curious about this phrasing (which I realize is identical to C39). I'm concerned this could be misinterpreted too strictly? i.e. if the "movement" is associated with new content appearing, or content being relocated, the content can still appear or relocate instantaneously rather than gradually via an animation, right? If you think I'm overthinking this and it should be fine given the context of the rest of the page, feel free to ignore. (This comment applies to both SCR40 and C39.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i hear you, particularly as the initial prose for the technique also seems a bit nuance-free "allow users to prevent animation from being displayed on web pages" maybe just qualifying this with something like "unnecessary and distracting animation" in the description, and modifying the check to something more like "Check that the element does not show an unnecessary or distracting animation" (but that's subjective, people cried...and I replied "yes, as that's the point ... not a blanket ban on animations in general, but reducing/removing the problematic ones) |
||
</ol> | ||
</section> | ||
<section class="test-results"> | ||
<h3>Expected Results</h3> | ||
<ul> | ||
<li>#2 and #3 are true.</li> | ||
</ul> | ||
</section> | ||
</section> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the 2 changelog files so SCR40 is the latest, and reflect when it's merged rather than when the PR was first written
(FWIW I have started working on a way to automate the entire Techniques Change Log; not sure which will get done first)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this here as comment for whoever merges this eventually ... update the changelog dates