WIP: feat/PausePlayButton closes #16, #30 #34

Draft
adrian wants to merge 16 commits from adrian/site:feat/PausePlayButton into feat/a11y
2 changed files with 23 additions and 22 deletions
Showing only changes of commit d30acf4e37 - Show all commits

View file

@ -47,7 +47,7 @@
<body>
<nav role="none" aria-label="boutton activer/desactiver les animations" id="play">
<ul aria-label="boutton activer/desactiver les animations" role="toolbar" class="toggleButton">
<ul aria-label="bouton activer/desactiver les animations" role="toolbar" class="toggleButton">
<li role="none">
<pre class="toggleable" aria-hidden="true">
|‾‾‾‾‾‾‾‾‾|

View file

@ -2,6 +2,7 @@ async function setupPage() {
// Checks if the user enabled prefers-reduced-motion
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
let animationEnabled = prefersReducedMotion;
// Dictionary to keep track of animation intervals
let animationIntervals = {};
// Dictionary to keep track of delay count for each animation
@ -17,8 +18,8 @@ async function setupPage() {
const parterre = document.getElementById('parterre');
// Update ARIA live attributes based on prefers-reduced-motion
function updateARIALiveAttributes() {
if (prefersReducedMotion) {
function setARIALiveAttributes(isAnimated) {
if (isAnimated) {
illustrationAccueil.setAttribute('aria-live', 'off');
rennes.setAttribute('aria-live', 'off');
orsay.setAttribute('aria-live', 'off');
@ -52,13 +53,11 @@ async function setupPage() {
delays[id] = delay;
// Update ARIA live attributes
updateARIALiveAttributes();
setARIALiveAttributes(true);
// Start the animation if prefers-reduced-motion is not enabled
if (!prefersReducedMotion) {
animationIntervals[id] = setInterval(updateAnimation, delay, id, framesList, framesList.length);
}
}
function updateAnimation(id, framesList, totalFrames) {
@ -76,10 +75,12 @@ async function setupPage() {
}
}
if (animationEnabled) {
animate("illustration-accueil", 500);
animate("rennes", 1000);
animate("orsay", 2000);
animate("parterre", 1500);
}
const toggleableElements = document.querySelectorAll('.toggleable, .img_top_toggleable');
toggleableElements.forEach(function (element) {