fix(embeds): pas d'iframe dans la copie cachée (AEP se chargeait deux fois sur bureau)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NesPD8Rbr37QVgqSBMMKmj
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fa88bd0a65
commit
d5fa176888
@@ -44,6 +44,10 @@ const progression = ref(0) // 0 → 1
|
||||
const mobile = ref(false)
|
||||
const scale = ref(0.42)
|
||||
const wrapperRef = ref<HTMLDivElement | null>(null)
|
||||
const rootRef = ref<HTMLDivElement | null>(null)
|
||||
// La page monte chaque colonne deux fois (grille bureau + SwipeContainer mobile caché) :
|
||||
// pas d'iframe tant que cette copie n'est pas affichée, sinon AEP se charge deux fois.
|
||||
const affiche = ref(false)
|
||||
|
||||
let raf = 0
|
||||
let dernier = 0
|
||||
@@ -82,8 +86,13 @@ const tick = (t: number) => {
|
||||
raf = requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
const majAffiche = () => {
|
||||
affiche.value = !!rootRef.value && rootRef.value.offsetParent !== null
|
||||
}
|
||||
|
||||
const onMqlMobile = () => {
|
||||
mobile.value = !!mqlMobile?.matches
|
||||
majAffiche()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -98,6 +107,7 @@ onMounted(() => {
|
||||
}
|
||||
// Le second site se charge en arrière-plan après quelques secondes, pour que le passage soit sans attente.
|
||||
setTimeout(() => montes.value.forEach((_, i) => (montes.value[i] = true)), 4000)
|
||||
window.addEventListener('resize', majAffiche)
|
||||
raf = requestAnimationFrame(tick)
|
||||
})
|
||||
|
||||
@@ -105,11 +115,13 @@ onUnmounted(() => {
|
||||
cancelAnimationFrame(raf)
|
||||
resizeObs?.disconnect()
|
||||
mqlMobile?.removeEventListener('change', onMqlMobile)
|
||||
window.removeEventListener('resize', majAffiche)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
ref="rootRef"
|
||||
class="embed-onglets h-full flex flex-col"
|
||||
@mouseenter="enPause = true"
|
||||
@mouseleave="enPause = false"
|
||||
@@ -191,7 +203,7 @@ onUnmounted(() => {
|
||||
<span class="text-neutral-400 text-sm">Chargement de {{ o.label }}...</span>
|
||||
</div>
|
||||
<iframe
|
||||
v-if="montes[i]"
|
||||
v-if="montes[i] && affiche"
|
||||
:src="o.url"
|
||||
:title="o.titre"
|
||||
class="absolute top-0 left-0 border-0"
|
||||
|
||||
Reference in New Issue
Block a user