fix(connaissances): B19 M6 — recette : libellés bornés au cadre (colonne étroite), recadrage animé aussi quand la fiche s'ouvre
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179wsewuntMrKBA2s9y7ZeX
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c1b26e5987
commit
0ff71d9b7f
@@ -263,7 +263,7 @@ const OPTIONS_PAS: { v: Pas; libelle: string }[] = [
|
||||
]
|
||||
const DUREE = 600 // recadrage : ≤ 700 ms, puis immobile
|
||||
const MARGE = { haut: 52, bas: 44, gauche: 96, droite: 96 }
|
||||
const MARGE_TEL = { haut: 52, bas: 84, gauche: 64, droite: 64 } // < 768 : le pied de la vue fiches couvre le bas
|
||||
const MARGE_TEL = { haut: 52, bas: 84, gauche: 80, droite: 80 } // < 768 : le pied de la vue fiches couvre le bas
|
||||
|
||||
// ── Taille mesurée (le rendu serveur part d'une taille plausible, comme GrapheMots) ──
|
||||
const racine = ref<HTMLElement | null>(null)
|
||||
@@ -277,14 +277,14 @@ onMounted(() => {
|
||||
mq.addEventListener('change', majMq)
|
||||
const el = racine.value
|
||||
if (el && typeof ResizeObserver !== 'undefined') {
|
||||
const maj = (w: number, h: number) => {
|
||||
const maj = (w: number, h: number, initiale = false) => {
|
||||
if (w > 40 && h > 40 && (Math.round(w) !== taille.w || Math.round(h) !== taille.h)) {
|
||||
redim = true
|
||||
redim = initiale // la première mesure saute ; un redimensionnement (fiche ouverte, fenêtre) se recadre en douceur
|
||||
taille.w = Math.round(w)
|
||||
taille.h = Math.round(h)
|
||||
}
|
||||
}
|
||||
maj(el.clientWidth, el.clientHeight)
|
||||
maj(el.clientWidth, el.clientHeight, true)
|
||||
const ro = new ResizeObserver((e) => { const r = e[0]?.contentRect; if (r) maj(r.width, r.height) })
|
||||
ro.observe(el)
|
||||
onBeforeUnmount(() => ro.disconnect())
|
||||
@@ -362,12 +362,20 @@ watch(cible, (c) => {
|
||||
raf = requestAnimationFrame(pasAnim)
|
||||
})
|
||||
|
||||
/** Bord à garder libre autour du centre d'un nœud : la demi-largeur maximale d'un libellé (9,5 rem) pour un principal. */
|
||||
const BORD_PRINCIPAL = 80
|
||||
const BORD_SECONDAIRE = 12
|
||||
const kindDe = computed(() => new Map(props.noeuds.map((x) => [x.id, x.kind])))
|
||||
const ecran = (id: string): Pt | null => {
|
||||
const p = pt(id)
|
||||
if (!p) return null
|
||||
const z = zone.value
|
||||
const x = (p.x - camera.cx) * camera.s + z.x + z.w / 2
|
||||
// Garde-fou : aucun libellé ne sort du cadre, même en pleine animation ou sur une colonne étroite.
|
||||
const b = principaux.value.has(kindDe.value.get(id) ?? '') ? BORD_PRINCIPAL : BORD_SECONDAIRE
|
||||
const xBorne = taille.w > 2 * b ? Math.min(taille.w - b, Math.max(b, x)) : x
|
||||
return {
|
||||
x: Math.round(((p.x - camera.cx) * camera.s + z.x + z.w / 2) * 10) / 10,
|
||||
x: Math.round(xBorne * 10) / 10,
|
||||
y: Math.round(((p.y - camera.cy) * camera.s + z.y + z.h / 2) * 10) / 10,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user