Hero: slow zoom on the first photo without replacing the plain HTML
Continuous Integration / check (pull_request) Successful in 1m57s
Continuous Integration / build-test (pull_request) Skipped
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 9m0s
Continuous Integration / deploy-production (pull_request) Skipped
Continuous Integration / check (pull_request) Successful in 1m57s
Continuous Integration / build-test (pull_request) Skipped
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 9m0s
Continuous Integration / deploy-production (pull_request) Skipped
The plain HTML is painted at scale 1.06 and the slider zooms it out to 1 after hydration, like the other photos: same first frame (no CLS), and the LCP does not wait for hydration. Assumptions 15 and 16 recorded. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,24 @@ describe('Hero', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('laat de eerste foto inzoomen zolang hij de actieve is', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<Hero content={heroContent} socials={siteContent.socials} />,
|
||||
);
|
||||
const picture = container.querySelector('.cms-hero-picture')!;
|
||||
expect(picture).toHaveAttribute('data-zoom');
|
||||
expect(picture).not.toHaveAttribute('aria-hidden');
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', { name: 'Volgende foto' }),
|
||||
);
|
||||
expect(picture).not.toHaveAttribute('data-zoom');
|
||||
expect(picture).toHaveAttribute('aria-hidden', 'true');
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', { name: 'Vorige foto' }),
|
||||
);
|
||||
expect(picture).toHaveAttribute('data-zoom');
|
||||
});
|
||||
|
||||
it('heeft pijlen met een toegankelijke naam', async () => {
|
||||
await renderWithProviders(
|
||||
<Hero content={heroContent} socials={siteContent.socials} />,
|
||||
|
||||
@@ -164,11 +164,17 @@ function HeroFrame({ content, socials, regionHtml, hydrated }: FrameProps) {
|
||||
}, [firstPainted]);
|
||||
|
||||
// The first photo is hidden from screen readers while another one is on
|
||||
// top of it
|
||||
// top of it, and it zooms (data-zoom, see .cms-hero-image) while it is the
|
||||
// active one
|
||||
useEffect(() => {
|
||||
const picture = section.current?.querySelector('.cms-hero-picture');
|
||||
if (active === 0) picture?.removeAttribute('aria-hidden');
|
||||
else picture?.setAttribute('aria-hidden', 'true');
|
||||
if (active === 0) {
|
||||
picture?.removeAttribute('aria-hidden');
|
||||
picture?.setAttribute('data-zoom', '');
|
||||
} else {
|
||||
picture?.setAttribute('aria-hidden', 'true');
|
||||
picture?.removeAttribute('data-zoom');
|
||||
}
|
||||
}, [active]);
|
||||
|
||||
const loaded = firstPainted ? slidesToLoad(active, shown.length) : [active];
|
||||
|
||||
@@ -55,6 +55,20 @@ const config = defineConfig({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
// Same slow zoom as the other photos of the slider: the plain HTML
|
||||
// is painted at 1.06 and the slider (after hydration) sets
|
||||
// data-zoom on the picture, which zooms out to 1 over 9 s. The
|
||||
// photo itself is never replaced, so the LCP does not wait for
|
||||
// hydration; the first frame is the same before and after it.
|
||||
transform: 'scale(1.06)',
|
||||
transition: 'transform 9s linear',
|
||||
'@media (prefers-reduced-motion: reduce)': {
|
||||
transform: 'none',
|
||||
transition: 'none',
|
||||
},
|
||||
},
|
||||
'.cms-hero-picture[data-zoom] .cms-hero-image': {
|
||||
transform: 'scale(1)',
|
||||
},
|
||||
'.cms-hero-title': {
|
||||
position: 'relative',
|
||||
|
||||
Reference in New Issue
Block a user