Свечение от центра контента письма

Добавлены @property --glow-x/y. После загрузки iframe вычисляется
его центр в % от viewport и записывается в переменные. ResizeObserver
обновляет позицию при ресайзе панели.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
vodyanoysh 2026-04-01 00:18:39 +07:00
parent 44e937fbe3
commit aef42950a6
2 changed files with 25 additions and 6 deletions

View file

@ -1,8 +1,10 @@
/* Регистрируем glow-компоненты как анимируемые свойства */
@property --glow-r { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-g { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-b { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-a { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-r { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-g { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-b { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-a { syntax: '<number>'; initial-value: 0; inherits: true; }
@property --glow-x { syntax: '<number>'; initial-value: 75; inherits: true; }
@property --glow-y { syntax: '<number>'; initial-value: 50; inherits: true; }
*,
*::before,
@ -27,7 +29,7 @@ body {
/* Rich gradient base — accent-glow и content-glow выставляются через JS */
background:
radial-gradient(ellipse 60% 50% at 15% 15%, var(--accent-glow, rgba(168,230,0,0.08)) 0%, transparent 70%),
radial-gradient(ellipse 95% 85% at 98% 50%, rgba(var(--glow-r), var(--glow-g), var(--glow-b), var(--glow-a)) 0%, transparent 60%),
radial-gradient(ellipse 95% 85% at calc(var(--glow-x) * 1%) calc(var(--glow-y) * 1%), rgba(var(--glow-r), var(--glow-g), var(--glow-b), var(--glow-a)) 0%, transparent 100%),
radial-gradient(ellipse 45% 55% at 88% 90%, rgba(0, 110, 220, 0.05) 0%, transparent 70%),
radial-gradient(ellipse 60% 40% at 50% 50%, rgba(80, 0, 160, 0.04) 0%, transparent 100%),
#09090e;

View file

@ -130,7 +130,21 @@ function clearContentGlow(): void {
setContentGlow(0, 0, 0, 0)
}
function updateGlowPosition(): void {
const el = iframeRef.value
if (!el) return
const rect = el.getBoundingClientRect()
const x = ((rect.left + rect.width / 2) / window.innerWidth) * 100
const y = ((rect.top + rect.height / 2) / window.innerHeight) * 100
document.documentElement.style.setProperty('--glow-x', x.toFixed(1))
document.documentElement.style.setProperty('--glow-y', y.toFixed(1))
}
const resizeObserver = new ResizeObserver(updateGlowPosition)
function onIframeLoad(): void {
updateGlowPosition()
if (iframeRef.value) resizeObserver.observe(iframeRef.value)
try {
const doc = iframeRef.value?.contentDocument
const view = iframeRef.value?.contentWindow
@ -161,7 +175,10 @@ function onIframeLoad(): void {
// Сбрасываем свечение при смене письма
watch(() => props.body, () => clearContentGlow())
onUnmounted(() => clearContentGlow())
onUnmounted(() => {
clearContentGlow()
resizeObserver.disconnect()
})
</script>
<template>