vercors.me : zones de clic des stations dynamiques (la plus proche du pointeur)
Les étiquettes et les points pouvaient se recouvrir (Saint-Jean-en-Royans et Rochechinard) : le clic tombait sur l'étiquette de la voisine. Désormais un clic ou un toucher sur la carte va à la station la plus proche du pointeur (distance à son étiquette ou à son point), dans un rayon borné : - zones à la Voronoï : elles se partagent la place quand les stations se serrent, s'étendent jusqu'au rayon quand la station est isolée ; - à égalité (pointeur sur une étiquette et sur le point d'une autre), le point le plus proche l'emporte ; - rayon 12 px à la souris, 24 px au doigt (cible d'au moins 24 px autour du point) ; - au survol, la station visée s'éclaire et le curseur devient une main ; - un double-clic dans la zone d'une station ne zoome pas ; la fin d'un glissé n'ouvre rien. Clavier inchangé : Tab sur les boutons, Entrée ou Espace ouvrent la fiche. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
4f05069abb
révision
075cd0fffc
2 fichiers modifiés
+114
-4
Aucun fichier ne correspond à votre recherche
@@ -95,7 +95,10 @@ a{color:inherit}
|
||||
.puce .fil{position:absolute;background:var(--roche);height:1px;transform-origin:0 0}
|
||||
.puce > button{position:absolute;font:inherit;color:inherit;text-align:left;cursor:pointer;white-space:nowrap;
|
||||
background:rgba(250,249,245,.95);border:1px solid var(--roche);border-radius:0;padding:4px 8px 5px}
|
||||
.puce > button:hover,.puce.ouverte > button{background:#fff}
|
||||
.puce.survol > button,.puce.ouverte > button{background:#fff}
|
||||
/* le clic ne passe pas par le point ni par le fil : c'est la zone de la station (la plus proche du pointeur) qui décide */
|
||||
.puce .pt,.puce .fil{pointer-events:none}
|
||||
.carte.vise:not(.glisse){cursor:pointer}
|
||||
.puce .val{display:inline-block;font-family:var(--titre);font-weight:600;font-size:21px;line-height:1;font-variant-numeric:tabular-nums}
|
||||
.puce .n{display:inline-block;margin-left:6px;padding:1px 4px;font-size:10.5px;font-weight:600;vertical-align:4px;background:var(--roche);color:#fff}
|
||||
.puce .nom{display:block;margin-top:3px;font-size:10px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
|
||||
@@ -108,7 +111,7 @@ a{color:inherit}
|
||||
.puce.ouverte .fiche li{animation:ligne .32s cubic-bezier(.2,.8,.2,1) both;animation-delay:calc(var(--i) * 45ms + 70ms)}
|
||||
.puce.ouverte > button{box-shadow:inset 0 -3px 0 var(--sapin)}
|
||||
.puce > button{transition:background .15s,transform .15s}
|
||||
.puce > button:hover{transform:translateY(-1px)}
|
||||
.puce.survol > button{transform:translateY(-1px)}
|
||||
@keyframes ouvre{from{opacity:0;transform:translateY(-6px);clip-path:inset(0 0 100% 0)}to{opacity:1;transform:none;clip-path:inset(0 0 0 0)}}
|
||||
@keyframes ligne{from{opacity:0;transform:translateX(-8px)}}
|
||||
.puce.ferme .fiche{animation:fermeture .17s ease-in forwards}
|
||||
@@ -772,6 +775,8 @@ carte.addEventListener('wheel', ev => {
|
||||
|
||||
carte.addEventListener('dblclick', ev => {
|
||||
if (ev.target.closest('button, a, .fiche, .cartouche, .commandes')) return;
|
||||
// double-clic dans la zone d'une station : c'est elle qu'on vise, pas un zoom
|
||||
if (stationProche(ev.pageX - posCarte[0], ev.pageY - posCarte[1], RAYON.mouse)) return;
|
||||
const r = carte.getBoundingClientRect();
|
||||
viser(autour(ev.shiftKey ? 0.5 : 2, ev.clientX - r.left, ev.clientY - r.top));
|
||||
});
|
||||
@@ -805,6 +810,55 @@ carte.addEventListener('pointermove', ev => {
|
||||
});
|
||||
['pointerup', 'pointercancel'].forEach(t => carte.addEventListener(t, ev => { doigts.delete(ev.pointerId); carte.classList.remove('glisse'); }));
|
||||
|
||||
// ---- zones de clic des stations ----
|
||||
// Un clic (ou un toucher) sur la carte va à la station la plus proche du pointeur : son étiquette ou son point.
|
||||
// Zones à la Voronoï bornées par un rayon : elles se partagent la place quand les stations se serrent
|
||||
// (Saint-Jean-en-Royans et sa voisine) et s'étendent jusqu'au rayon quand la station est isolée.
|
||||
// Au doigt, le rayon donne au moins 24 px de cible autour du point. Le clavier passe par les boutons eux-mêmes.
|
||||
const RAYON = {mouse: 12, pen: 16, touch: 24};
|
||||
const HORS_ZONES = '.fiche, .cartouche, .commandes, .forum-box, .legende, .thermo, .suite';
|
||||
let posCarte = [0, 0]; // position de la carte dans la page, relevée au placement complet (pas de lecture au clic)
|
||||
function stationProche(mx, my, rayon){
|
||||
let meilleure = null, dMin = Infinity, dPt = Infinity;
|
||||
for (const p of puces) {
|
||||
if (p.etat !== 'vue' || !p.vis) continue;
|
||||
const bx = p.x + p.dx, by = p.y + p.dy;
|
||||
const ex = Math.max(bx - mx, 0, mx - bx - p.bw), ey = Math.max(by - my, 0, my - by - p.bh);
|
||||
const dp = Math.max(0, Math.hypot(mx - p.x, my - p.y) - 6); // le point compte pour un disque de 6 px
|
||||
const d = Math.min(Math.hypot(ex, ey), dp);
|
||||
// à égalité (pointeur sur une étiquette et sur le point d'une autre) : le point le plus proche l'emporte
|
||||
if (d < dMin - 0.5 || (d <= dMin + 0.5 && dp < dPt)) { meilleure = p; dMin = d; dPt = dp; }
|
||||
}
|
||||
return dMin <= rayon ? meilleure : null;
|
||||
}
|
||||
let typePointeur = 'mouse', depart = null;
|
||||
carte.addEventListener('pointerdown', ev => { typePointeur = ev.pointerType || 'mouse'; depart = [ev.clientX, ev.clientY]; }, true);
|
||||
carte.addEventListener('click', ev => {
|
||||
if (!ev.detail || ev.target.closest(HORS_ZONES)) return; // clavier (Entrée, Espace) : le bouton s'en charge
|
||||
if (depart && Math.hypot(ev.clientX - depart[0], ev.clientY - depart[1]) > 6) return; // fin d'un glissé
|
||||
const p = stationProche(ev.pageX - posCarte[0], ev.pageY - posCarte[1], RAYON[typePointeur] || RAYON.mouse);
|
||||
if (!p) return;
|
||||
ev.stopPropagation(); ev.preventDefault();
|
||||
ouvrir(p);
|
||||
}, true);
|
||||
// survol à la souris : la station qui recevra le clic s'éclaire (une fois par image au plus)
|
||||
let survol = null, survolXY = null, survolId = 0;
|
||||
function majSurvol(){
|
||||
survolId = 0;
|
||||
const p = survolXY && !doigts.size ? stationProche(survolXY[0] - posCarte[0], survolXY[1] - posCarte[1], RAYON.mouse) : null;
|
||||
if (p === survol) return;
|
||||
if (survol) survol.m.classList.remove('survol');
|
||||
survol = p;
|
||||
if (p) p.m.classList.add('survol');
|
||||
carte.classList.toggle('vise', !!p);
|
||||
}
|
||||
carte.addEventListener('pointermove', ev => {
|
||||
if (ev.pointerType !== 'mouse') return;
|
||||
survolXY = ev.target.closest(HORS_ZONES) ? null : [ev.pageX, ev.pageY];
|
||||
if (!survolId) survolId = requestAnimationFrame(majSurvol);
|
||||
});
|
||||
carte.addEventListener('pointerleave', () => { survolXY = null; if (!survolId) survolId = requestAnimationFrame(majSurvol); });
|
||||
|
||||
document.getElementById('plus').addEventListener('click', () => { const z = Z || zone(); viser(autour(2, z.cx, z.cy)); });
|
||||
document.getElementById('moins').addEventListener('click', () => { const z = Z || zone(); viser(autour(0.5, z.cx, z.cy)); });
|
||||
|
||||
@@ -884,6 +938,7 @@ function disposer(){
|
||||
// 1. lectures
|
||||
const z = Z = zone(), {W, H, mob, r0} = z, s = vue.s;
|
||||
const vx = vue.cx - z.cx / s, vy = vue.cy - z.cy / s;
|
||||
posCarte = [r0.left + scrollX, r0.top + scrollY];
|
||||
calcul = performance.now();
|
||||
const ecran = ([x, y]) => [(x - vx) * s, (y - vy) * s];
|
||||
const marge = r => ({left: r.left - 8, top: r.top - 8, right: r.right + 8, bottom: r.bottom + 8});
|
||||
|
||||
@@ -95,7 +95,10 @@ a{color:inherit}
|
||||
.puce .fil{position:absolute;background:var(--roche);height:1px;transform-origin:0 0}
|
||||
.puce > button{position:absolute;font:inherit;color:inherit;text-align:left;cursor:pointer;white-space:nowrap;
|
||||
background:rgba(250,249,245,.95);border:1px solid var(--roche);border-radius:0;padding:4px 8px 5px}
|
||||
.puce > button:hover,.puce.ouverte > button{background:#fff}
|
||||
.puce.survol > button,.puce.ouverte > button{background:#fff}
|
||||
/* le clic ne passe pas par le point ni par le fil : c'est la zone de la station (la plus proche du pointeur) qui décide */
|
||||
.puce .pt,.puce .fil{pointer-events:none}
|
||||
.carte.vise:not(.glisse){cursor:pointer}
|
||||
.puce .val{display:inline-block;font-family:var(--titre);font-weight:600;font-size:21px;line-height:1;font-variant-numeric:tabular-nums}
|
||||
.puce .n{display:inline-block;margin-left:6px;padding:1px 4px;font-size:10.5px;font-weight:600;vertical-align:4px;background:var(--roche);color:#fff}
|
||||
.puce .nom{display:block;margin-top:3px;font-size:10px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
|
||||
@@ -108,7 +111,7 @@ a{color:inherit}
|
||||
.puce.ouverte .fiche li{animation:ligne .32s cubic-bezier(.2,.8,.2,1) both;animation-delay:calc(var(--i) * 45ms + 70ms)}
|
||||
.puce.ouverte > button{box-shadow:inset 0 -3px 0 var(--sapin)}
|
||||
.puce > button{transition:background .15s,transform .15s}
|
||||
.puce > button:hover{transform:translateY(-1px)}
|
||||
.puce.survol > button{transform:translateY(-1px)}
|
||||
@keyframes ouvre{from{opacity:0;transform:translateY(-6px);clip-path:inset(0 0 100% 0)}to{opacity:1;transform:none;clip-path:inset(0 0 0 0)}}
|
||||
@keyframes ligne{from{opacity:0;transform:translateX(-8px)}}
|
||||
.puce.ferme .fiche{animation:fermeture .17s ease-in forwards}
|
||||
@@ -772,6 +775,8 @@ carte.addEventListener('wheel', ev => {
|
||||
|
||||
carte.addEventListener('dblclick', ev => {
|
||||
if (ev.target.closest('button, a, .fiche, .cartouche, .commandes')) return;
|
||||
// double-clic dans la zone d'une station : c'est elle qu'on vise, pas un zoom
|
||||
if (stationProche(ev.pageX - posCarte[0], ev.pageY - posCarte[1], RAYON.mouse)) return;
|
||||
const r = carte.getBoundingClientRect();
|
||||
viser(autour(ev.shiftKey ? 0.5 : 2, ev.clientX - r.left, ev.clientY - r.top));
|
||||
});
|
||||
@@ -805,6 +810,55 @@ carte.addEventListener('pointermove', ev => {
|
||||
});
|
||||
['pointerup', 'pointercancel'].forEach(t => carte.addEventListener(t, ev => { doigts.delete(ev.pointerId); carte.classList.remove('glisse'); }));
|
||||
|
||||
// ---- zones de clic des stations ----
|
||||
// Un clic (ou un toucher) sur la carte va à la station la plus proche du pointeur : son étiquette ou son point.
|
||||
// Zones à la Voronoï bornées par un rayon : elles se partagent la place quand les stations se serrent
|
||||
// (Saint-Jean-en-Royans et sa voisine) et s'étendent jusqu'au rayon quand la station est isolée.
|
||||
// Au doigt, le rayon donne au moins 24 px de cible autour du point. Le clavier passe par les boutons eux-mêmes.
|
||||
const RAYON = {mouse: 12, pen: 16, touch: 24};
|
||||
const HORS_ZONES = '.fiche, .cartouche, .commandes, .forum-box, .legende, .thermo, .suite';
|
||||
let posCarte = [0, 0]; // position de la carte dans la page, relevée au placement complet (pas de lecture au clic)
|
||||
function stationProche(mx, my, rayon){
|
||||
let meilleure = null, dMin = Infinity, dPt = Infinity;
|
||||
for (const p of puces) {
|
||||
if (p.etat !== 'vue' || !p.vis) continue;
|
||||
const bx = p.x + p.dx, by = p.y + p.dy;
|
||||
const ex = Math.max(bx - mx, 0, mx - bx - p.bw), ey = Math.max(by - my, 0, my - by - p.bh);
|
||||
const dp = Math.max(0, Math.hypot(mx - p.x, my - p.y) - 6); // le point compte pour un disque de 6 px
|
||||
const d = Math.min(Math.hypot(ex, ey), dp);
|
||||
// à égalité (pointeur sur une étiquette et sur le point d'une autre) : le point le plus proche l'emporte
|
||||
if (d < dMin - 0.5 || (d <= dMin + 0.5 && dp < dPt)) { meilleure = p; dMin = d; dPt = dp; }
|
||||
}
|
||||
return dMin <= rayon ? meilleure : null;
|
||||
}
|
||||
let typePointeur = 'mouse', depart = null;
|
||||
carte.addEventListener('pointerdown', ev => { typePointeur = ev.pointerType || 'mouse'; depart = [ev.clientX, ev.clientY]; }, true);
|
||||
carte.addEventListener('click', ev => {
|
||||
if (!ev.detail || ev.target.closest(HORS_ZONES)) return; // clavier (Entrée, Espace) : le bouton s'en charge
|
||||
if (depart && Math.hypot(ev.clientX - depart[0], ev.clientY - depart[1]) > 6) return; // fin d'un glissé
|
||||
const p = stationProche(ev.pageX - posCarte[0], ev.pageY - posCarte[1], RAYON[typePointeur] || RAYON.mouse);
|
||||
if (!p) return;
|
||||
ev.stopPropagation(); ev.preventDefault();
|
||||
ouvrir(p);
|
||||
}, true);
|
||||
// survol à la souris : la station qui recevra le clic s'éclaire (une fois par image au plus)
|
||||
let survol = null, survolXY = null, survolId = 0;
|
||||
function majSurvol(){
|
||||
survolId = 0;
|
||||
const p = survolXY && !doigts.size ? stationProche(survolXY[0] - posCarte[0], survolXY[1] - posCarte[1], RAYON.mouse) : null;
|
||||
if (p === survol) return;
|
||||
if (survol) survol.m.classList.remove('survol');
|
||||
survol = p;
|
||||
if (p) p.m.classList.add('survol');
|
||||
carte.classList.toggle('vise', !!p);
|
||||
}
|
||||
carte.addEventListener('pointermove', ev => {
|
||||
if (ev.pointerType !== 'mouse') return;
|
||||
survolXY = ev.target.closest(HORS_ZONES) ? null : [ev.pageX, ev.pageY];
|
||||
if (!survolId) survolId = requestAnimationFrame(majSurvol);
|
||||
});
|
||||
carte.addEventListener('pointerleave', () => { survolXY = null; if (!survolId) survolId = requestAnimationFrame(majSurvol); });
|
||||
|
||||
document.getElementById('plus').addEventListener('click', () => { const z = Z || zone(); viser(autour(2, z.cx, z.cy)); });
|
||||
document.getElementById('moins').addEventListener('click', () => { const z = Z || zone(); viser(autour(0.5, z.cx, z.cy)); });
|
||||
|
||||
@@ -884,6 +938,7 @@ function disposer(){
|
||||
// 1. lectures
|
||||
const z = Z = zone(), {W, H, mob, r0} = z, s = vue.s;
|
||||
const vx = vue.cx - z.cx / s, vy = vue.cy - z.cy / s;
|
||||
posCarte = [r0.left + scrollX, r0.top + scrollY];
|
||||
calcul = performance.now();
|
||||
const ecran = ([x, y]) => [(x - vx) * s, (y - vy) * s];
|
||||
const marge = r => ({left: r.left - 8, top: r.top - 8, right: r.right + 8, bottom: r.bottom + 8});
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur