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

Draft
adrian wants to merge 16 commits from adrian/site:feat/PausePlayButton into feat/a11y
4 changed files with 1132 additions and 963 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ public/
node_modules/
*.swp
.awsclirc
.idea

View file

@ -119,6 +119,31 @@ footer {
margin-bottom: var(--med_margin)
}
.toggleButton {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 999;
}
.toggleable {
padding-top: 1rem;
color: black;
cursor: pointer;
}
.img_top_toggleable {
display: none;
position: absolute;
top: 1rem;
right: 0;
z-index: 99;
background-color: var(--day-background);
color: darkgreen;
cursor: pointer;
}
/* MENU */
nav#menu{
background-color: var(--day-background);
@ -236,12 +261,16 @@ pre.center > a{
/* THEME SOMBRE */
@media (prefers-color-scheme: dark) {
div#container, nav#menu, body{
div#container, nav#menu, body, nav#play{
background-color: var(--night-background);
}
p, pre, ul, li, a, a:hover, h1, h2, footer{
color: var(--txt-night);
}
.img_top_toggleable, .toggleable {
color: var(--txt-night);
background-color: var(--night-background);
}
.highlight{
color: var(--night-highlight-color);
background-color: var(--night-highlight-bg);

View file

@ -7,6 +7,7 @@
-->
<html lang="fr">
<head>
<meta name="robots" content="noindex">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, height=device-height, minimum-scale=1.0">
@ -45,8 +46,23 @@
<body>
<nav role="navigation" aria-label="menu d'accès" id="menu">
<ul aria-label="menu principal" role="menubar" aria-orientation="vertical">
<nav role="none" aria-label="boutton activer/desactiver les animations" id="play">
<ul aria-label="bouton activer/desactiver les animations" role="toolbar" class="toggleButton">
<li role="none">
<pre class="toggleable" aria-hidden="true">
|‾‾‾‾‾‾‾‾‾|
| ▶ |
|_________| </pre>
<pre class="img_top_toggleable" aria-hidden="true">
|‾‾‾‾‾‾‾‾‾|
| ▐ ▐ |
|_________| </pre>
</li>
</ul>
</nav>
<nav role="navigation" aria-label="menu d'accès" id="menu">
<ul aria-label="menu principal" role="menubar">
<li role="none">
<a href="https://guichet.deuxfleurs.fr/" role="menuitem" aria-label="compte" class="icone">
<pre aria-hidden="true">
@ -81,7 +97,7 @@
</li>
<li role="none">
<a href="https://plume.deuxfleurs.fr/" role="menuitem" aria-label="blog" class="icone">
<pre aria-hidden="true">
<pre aria-hidden="true" >
|¨¨¨¨|
|BLOG|
(|____|)
@ -96,9 +112,9 @@
</a>
</li>
</ul>
</nav>
</nav>
<div id="container">
<div id="container">
<header>
<h1 id="deuxfleurs"><span role="img" aria-label="2 emojis fleur blanche">💮💮 </span>deuxfleurs</h1>
@ -108,7 +124,7 @@
<div id="jardin">
<div id="illustration-accueil" class="noscroll" role="img" aria-label="deux fleurs dessinées en ascii animées">
<!-- séquences de l'animation qui est lancée grâce à l'avant avant dernière ligne -->
<pre class="center">
<pre class="center" aria-label="Animation de texte de bienvenue">
'\ ; /'
·`.;.;.`·
·— · · —·
@ -868,9 +884,10 @@
<li role="none"><a href="https://jitsi.deuxfleurs.fr/r%C3%A9union_mensuelle_deuxfleurs">Réunion mensuelle «au coin du feu»</a> en ligne, <span class="highlight">le 9 janvier 2024 à 19h00</span>.<br>Une fois par mois nous organisons une réunion en ligne informelle. C'est le bon moment pour venir faire un coucou si vous voulez parler à des gens de vive voix numérique.</li>
<li role="none"><a href="https://www.agendadulibre.org/events/29139">Quadrapéro</a>, au Garage de la Quadrature du Net à Paris, <span class="highlight">le 19 janvier 2024 à 19h00</span>.<br>Apéritif convivial pour discuter des divers enjeux en cours autour des droits et libertés numériques, en présence de membres de la Quadrature du Net et de bien autres intéressés. Vous y verrez Vincent.</li>
<li role="none"><a href="https://jitsi.deuxfleurs.fr/infra">Réunion mensuelle d'infrastructure</a> en ligne, <span class="highlight">le 24 janvier 2024 à 20h00</span>.<br>Point mensuel en visioconférence où l'on aborde toutes les questions techniques qui méritent notre attention, concernant notre infrastructure ou nos services.</li>
<li role="none"><a href="#">Permanence associative autour du Libre</a> au Café Citoyen à Lille, <span class="highlight">le 25 janvier 2024 à 19h30</span>.<br>La permanence associative autour du Libre est une manifestation conviviale, ouverte à toutes et tous, organisée le dernier mardi de chaque mois, et regroupant les collectifs Chtinux, Raoull, Deuxfleurs, Mycélium, CLX et Cliss XXI.</li>
<li role="none"><a href="https://jitsi.deuxfleurs.fr/ag2024">Assemblée générale ordinaire</a> en ligne, <span class="highlight">le 28 janvier 2024 à 15h00</span>.<br>L'association Deuxfleurs organise sa cinquième assemblée générale. Divers sujets seront abordés, avec notamment l'élection du nouveau bureau pour un an. Vous pourrez y voir tous les membres ou presque.
<li role="none"><a href="#">Permanence associative autour du Libre</a> au Café Citoyen à Lille, <span class="highlight">le 30 janvier 2024 à 19h30</span>.<br>La permanence associative autour du Libre est une manifestation conviviale, ouverte à toutes et tous, organisée le dernier mardi de chaque mois, et regroupant les collectifs Chtinux, Raoull, Deuxfleurs, Mycélium, CLX et Cliss XXI.</li>
<!-- Février 2024 -->
<li role="none"><a href="https://journee-ecoconception-numerique.fr/">Journée de l'écoconception numérique</a> à Paris, <span class="highlight">le 1er février 2024</span>.<br> Pour rassembler la communauté des professionnels du numérique autour de l'écoconception numérique. Quentin y sera.</li>
<li role="none"><a href="https://fosdem.org/2024/">FOSDEM</a> à Bruxelles, <span class="highlight">les 3 et 4 février 2024</span>.<br>Pas moins de 7 membres de Deuxfleurs seront sur place, et il y aura 3 présentations de membres de Deuxfleurs&nbsp;: sur <a href="https://fosdem.org/2024/schedule/event/fosdem-2024-3009-advances-in-garage-the-low-tech-storage-platform-for-geo-distributed-clusters/">Garage</a>, <a href="https://fosdem.org/2024/schedule/event/fosdem-2024-2642--servers-aerogramme-a-multi-region-imap-server/">Aérogramme</a>, et <a href="https://fosdem.org/2024/schedule/event/fosdem-2024-3011-a-microkernel-based-orchestrator-for-distributed-internet-services-/">l'orchestration basée sur les microkernels</a>.</li>
<li role="none"><a href="https://jitsi.deuxfleurs.fr/r%C3%A9union_mensuelle_deuxfleurs">Réunion mensuelle «au coin du feu»</a> en ligne, <span class="highlight">le 6 février 2024 à 19h00</span>.<br>Une fois par mois nous organisons une réunion en ligne informelle. C'est le bon moment pour venir faire un coucou si vous voulez parler à des gens de vive voix numérique.</li>
<li role="none"><a href="https://jitsi.deuxfleurs.fr/infra">Réunion mensuelle d'infrastructure</a> en ligne, <span class="highlight">le 21 février 2024 à 20h00</span>.<br>Point mensuel en visioconférence où l'on aborde toutes les questions techniques qui méritent notre attention, concernant notre infrastructure ou nos services.</li>
@ -894,9 +911,9 @@
| ———— ———— ———— ———— ———— ———— ———— |
| | 15 | 16 | 17 | 18 |<span class="highlight"> 19 </span>| 20 | 21 | |
| ———— ———— ———— ———— ———— ———— ———— |
| | 22 | 23 |<span class="highlight"> 24 </span>| 25 | 26 | 27 |<span class="highlight"> 28 </span>| |
| | 22 | 23 |<span class="highlight"> 24 </span>|<span class="highlight"> 25 </span>| 26 | 27 |<span class="highlight"> 28 </span>| |
| ———— ———— ———— ———— ———— ———— ———— |
| | 29 |<span class="highlight"> 30 </span>| 31 | |
| | 29 | 30 | 31 | |
| ———— ———— ———— |
|______________________________________|</pre>
</div>
@ -905,7 +922,7 @@
| CALENDRIER FÉVRIER 2024 |
|——————————————————————————————————————|
| ———— ———— ———— ———— |
| | 01 | 02 |<span class="highlight"> 03 </span>|<span class="highlight"> 04 </span>| |
| |<span class="highlight"> 01 </span>| 02 |<span class="highlight"> 03 </span>|<span class="highlight"> 04 </span>| |
| ———— ———— ———— ———— ———— ———— ———— |
| | 05 |<span class="highlight"> 06 </span>| 07 | 08 | 09 | 10 | 11 | |
| ———— ———— ———— ———— ———— ———— ———— |
@ -917,7 +934,7 @@
| ———— ———— ———— ———— |
|______________________________________|</pre>
</div>
</div>
</main>
<footer class="noscroll" aria-label="pied de page et liens vers CGU, mentions, sources et risques">
<div id="parterre" role="img" aria-label="image d'un parterre de fleurs qui fleurit">
@ -1394,8 +1411,8 @@ _ ` ^ ¨ · _ - " ` * - ; - _
<a href="https://guide.deuxfleurs.fr/vie_associative/cgu/">CGU</a><span role="separator"> · </span><a href="https://guide.deuxfleurs.fr/vie_associative/gestion-des-risques/">Gestion des risques</a><span role="separator"> · </span><a href="https://guide.deuxfleurs.fr/vie_associative/mentions-legales">Mentions légales</a><span role="separator"> · </span><a href="https://guide.deuxfleurs.fr/operations/sources">Sources</a>
</div>
</footer>
</div>
<!-- script animations -->
<script src="script-bon.js"></script>
</div>
<!-- script animations -->
<script src="script-bon.js"></script>
</body>
</html>

View file

@ -1,44 +1,166 @@
// dictionary to keep track of frame count for each animation
let frameCounts = {};
// Loads the script once the document is ready
document.addEventListener('DOMContentLoaded', function() {
setupPage();
});
function animate(id, delay) {
function setupPage() {
// Checks if the user didn't enable prefers-reduced-motion
let animationEnabled = window.matchMedia('(prefers-reduced-motion: no-preference)').matches;
// Boolean to keep track of current animation state
let currentAnimationState = true;
if (!animationEnabled) {
currentAnimationState = false;
}
console.log(currentAnimationState);
// Dictionary to keep track of animation intervals
let animationIntervals = {};
// Dictionary to keep track of delay count for each animation
let delays = {};
// Dictionary to keep track of frame for each animation
let frames = {};
// dictionary to keep track of frame count for each animation
let frameCounts = {};
// Buttons for toggling
const toggleable = document.querySelector('.toggleable');
const imgTopToggleable = document.querySelector('.img_top_toggleable');
// get the container and frames for the amination
const illustrationAccueil = document.getElementById('illustration-accueil');
const rennes = document.getElementById('rennes');
const orsay = document.getElementById('orsay');
const parterre = document.getElementById('parterre');
// Update ARIA live attributes based on prefers-reduced-motion
function setARIALiveAttributes(isAnimated) {
if (isAnimated) {
illustrationAccueil.setAttribute('aria-live', 'off');
rennes.setAttribute('aria-live', 'off');
orsay.setAttribute('aria-live', 'off');
parterre.setAttribute('aria-live', 'off');
} else {
illustrationAccueil.setAttribute('aria-live', 'polite');
rennes.setAttribute('aria-live', 'polite');
orsay.setAttribute('aria-live', 'polite');
parterre.setAttribute('aria-live', 'polite');
}
}
function animate(id, delay) {
// get the container and frames for the animation
const container = document.getElementById(id);
const frames = container.children;
const framesList = container.children;
// set up the frame counter
frameCounts[id] = 0;
// hide all frames except for the first
frames[0].style.display = "flex";
for (let i = 1; i < frames.length; i++) {
frames[i].style.display = "none";
framesList[0].style.display = "flex";
for (let i = 1; i < framesList.length; i++) {
framesList[i].style.display = "none";
}
// start the animation
const interval = setInterval(updateAnimation, delay, id, frames, frames.length);
// Stock frames and delay in dictionaries
frames[id] = framesList;
delays[id] = delay;
}
// Update ARIA live attributes
setARIALiveAttributes(true);
function updateAnimation(id, frames, totalFrames) {
animationIntervals[id] = setInterval(updateAnimation, delay, id, framesList, framesList.length);
}
function updateAnimation(id, framesList, totalFrames) {
// increment the frame counter for the given id
frameCounts[id] = (frameCounts[id] + 1) % totalFrames;
// show the next frame
frames[frameCounts[id]].style.display = "flex";
framesList[frameCounts[id]].style.display = "flex";
// hide the previous frame
if (frameCounts[id] == 0) {
frames[totalFrames - 1].style.display = "none";
if (frameCounts[id] === 0) {
framesList[totalFrames - 1].style.display = "none";
} else {
frames[frameCounts[id] - 1].style.display = "none";
framesList[frameCounts[id] - 1].style.display = "none";
}
}
console.log(currentAnimationState);
// Start the animation if animation is enabled
if (currentAnimationState) {
animate("illustration-accueil", 500);
animate("rennes", 1000);
animate("orsay", 2000);
animate("parterre", 1500);
}
// Pause the animation if animation is disabled, initialization of the animation is necessary for the first time
else if(!currentAnimationState){
animate("illustration-accueil", 500);
animate("rennes", 1000);
animate("orsay", 2000);
animate("parterre", 1500);
//Display the pause button at first
toggleable.style.display = 'none';
imgTopToggleable.style.display = 'block';
setARIALiveAttributes(false);
Object.keys(animationIntervals).forEach(id => {
clearInterval(animationIntervals[id]);
});
}
}
const toggleableElements = document.querySelectorAll('.toggleable, .img_top_toggleable');
toggleableElements.forEach(function(element) {
element.addEventListener('click', function() {
toggleAnimation();
});
});
animate("illustration-accueil", 500);
animate("rennes", 1000);
animate("orsay", 2000);
animate("parterre", 1500);
function toggleAnimation() {
// Play or pause the animations based on current state
if (currentAnimationState) {
// Pause the animations
toggleable.style.display = 'none';
imgTopToggleable.style.display = 'block';
setARIALiveAttributes(false);
Object.keys(animationIntervals).forEach(id => {
clearInterval(animationIntervals[id]);
});
} else {
// Play the animations
toggleable.style.display = 'block';
imgTopToggleable.style.display = 'none';
setARIALiveAttributes(true);
Object.keys(animationIntervals).forEach(id => {
animationIntervals[id] = setInterval(updateAnimation, delays[id], id, frames[id], frames[id].length);
});
}
// Toggle animation state
currentAnimationState = !currentAnimationState;
}
let lastScrollTop = 0;
let isCallbackRegistered = false;
window.addEventListener("scroll", function() {
const toggleButton = document.querySelectorAll('.toggleButton');
if (!isCallbackRegistered) {
window.requestAnimationFrame(function () {
let currentPosition = window.scrollY || document.documentElement.scrollTop;
if (currentPosition > lastScrollTop) {
// Scroll down
toggleButton.forEach(button => {
button.style.display = "none";
});
} else {
// Scroll up
toggleButton.forEach(button => {
button.style.display = "block";
});
}
lastScrollTop = currentPosition <= 0 ? 0 : currentPosition; // For Mobile or negative scrolling
isCallbackRegistered = false;
});
isCallbackRegistered = true;
}
});
}