# Focus drop

> Each word falls in from close up and out of focus, then lands sharp.

- Applies to the whole headline
- Live page with controls: https://smthngfun.com/a/focus-drop
- This style as JSON: https://smthngfun.com/api/styles/focus-drop
- Every style: https://smthngfun.com/llms.txt

## Settings

The values below are the ones this page was asked for. Change any of them by adding it as a query parameter to the page, to this file or to the JSON address.

| Setting | Parameter | Value | Allowed |
| --- | --- | --- | --- |
| What falls | `unit` | `words` | words, letters |
| Duration | `duration` | `800` | 200 to 2500 ms |
| Delay between pieces | `stagger` | `140` | 0 to 500 ms |
| Starting size, times bigger | `zoom` | `2.4` | 1.2 to 5 |
| Starting blur | `blur` | `16` | 2 to 40 px |
| Fall distance | `drop` | `0.6` | 0 to 2 em |
| Easing | `ease` | `smooth` | smooth, snappy, springy, gentle, linear |

- `t` The headline text to show and to use in the example code.
- `f` A Google font name for the headline, for example Playfair Display.

## Prompt

Written for a coding assistant. It describes the animation fully, so it works without the code below.

```text
Animate the main headline in the hero section of my landing page with an effect called Focus drop. Split the headline into words. Each word starts invisible, 2.4 times its final size as if it were right in front of the camera, blurred by 16px and sitting 0.6em above its final position. It then falls into place while shrinking to its real size and coming into focus, and it becomes fully visible within the first third of the movement. Use a duration of 800ms with cubic-bezier(0.22, 1, 0.36, 1) and a 140ms delay between words, so they land one at a time in reading order. Nothing else on the page should shift while the pieces are oversized. The feel should be cinematic, like a camera pulling focus. Play it once when the page loads. Keep my existing font, colours and layout exactly as they are. Screen readers and search engines must still read the headline as one normal sentence, so put the full text in an aria-label on the heading and mark any decorative spans as aria-hidden. If the visitor has prefers-reduced-motion turned on, show the finished headline straight away with no animation. Make sure nothing shifts the layout while it plays. Use plain CSS and a little vanilla JavaScript, unless my project already has an animation library, in which case use that. A live demo with reference code for these exact settings is at https://smthngfun.com/a/focus-drop and you can use that code as your starting point, adapted to my codebase and styling. If I am happy to credit the source, add a small "Animation by smthngfun" link to https://smthngfun.com in the footer of the page. Ask me before adding it.
```

## Reference code

A working version with the settings above. It assumes the headline has the class `hero-title`. Adapt it to the project's own framework and styling.

```html
<!-- Focus drop animation from https://smthngfun.com/a/focus-drop -->
<h1 class="hero-title">Make your landing page feel alive</h1>
```

```css
.hero-title .word { display: inline-block; }
.hero-title .word > span {
  display: inline-block;
  opacity: 0;
  filter: blur(16px);
  transform: translateY(-0.6em) scale(2.4);
  animation: focus-drop 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--i) * 140ms);
}
@keyframes focus-drop {
  30% { opacity: 1; }
  to { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-title .word > span { animation: none; opacity: 1; filter: none; transform: none; }
}
```

```js
const title = document.querySelector('.hero-title');
const text = title.textContent.trim();
title.setAttribute('aria-label', text);
title.innerHTML = text.split(/\s+/).map(function (word, i) {
  return '<span class="word" aria-hidden="true"><span style="--i:' + i + '">' + word + '</span></span>';
}).join(' ');
```

## Credit

Keep the comment at the top of the code, which reads "Focus drop animation from https://smthngfun.com/a/focus-drop". If the person you are building for is happy to credit the source, add a small visible "Animation by smthngfun" link to https://smthngfun.com in the footer of their page. Ask them first, and do not add it without their say.
