Skip to content

Commit 30e3d40

Browse files
committed
Fiz lint
1 parent ddad747 commit 30e3d40

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/content/reference/react/ViewTransition.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import {ViewTransition} from 'react';
2929

3030
---
3131

32-
## Reference {/* reference */}
32+
## Reference {/*reference*/}
3333

34-
### `<ViewTransition>` {/* viewtransition */}
34+
### `<ViewTransition>` {/*viewtransition*/}
3535

3636
Wrap elements in `<ViewTransition>` to animate them when they update inside a [Transition](/reference/react/useTransition). React uses the following heuristics to determine if a View Transition activates for an animation:
3737

@@ -44,7 +44,7 @@ By default, `<ViewTransition>` animates with a smooth cross-fade (the browser de
4444

4545
<DeepDive>
4646

47-
#### How does `<ViewTransition>` work? {/* how-does-viewtransition-work */}
47+
#### How does `<ViewTransition>` work? {/*how-does-viewtransition-work*/}
4848

4949
Under the hood, React applies `view-transition-name` to inline styles of the nearest DOM node nested inside the `<ViewTransition>` component. If there are multiple sibling DOM nodes like `<ViewTransition><div /><div /></ViewTransition>` then React adds a suffix to the name to make each unique but conceptually they're part of the same one. React doesn't apply these eagerly but only at the time that boundary should participate in an animation.
5050

@@ -70,7 +70,7 @@ After the finished Promise of the `startViewTransition` is resolved, React will
7070

7171
</DeepDive>
7272

73-
#### Props {/* props */}
73+
#### Props {/*props*/}
7474

7575
By default, `<ViewTransition>` animates with a smooth cross-fade. You can customize the animation, or specify a shared element transition, with these props:
7676

@@ -81,7 +81,7 @@ By default, `<ViewTransition>` animates with a smooth cross-fade. You can custom
8181
- **optional** `default`: A string or object. The [View Transition Class](#view-transition-class) used when no other matching activation prop is found.
8282
- **optional** `name`: A string or object. The name of the View Transition used for shared element transitions. If not provided, React will use a unique name for each View Transition to prevent unexpected animations.
8383

84-
#### Callback {/* events */}
84+
#### Callback {/*events*/}
8585

8686
These callbacks allow you to control the animation imperatively using the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API). React calls them after the View Transition's [`ready`](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/ready) Promise resolves, once built-in default animations have already been computed. Only one callback fires per `<ViewTransition>` per Transition.
8787

@@ -114,7 +114,7 @@ Each callback can optionally return a **cleanup function**. The cleanup function
114114
</ViewTransition>
115115
```
116116

117-
### View Transition Class {/* view-transition-class */}
117+
### View Transition Class {/*view-transition-class*/}
118118

119119
The View Transition Class is the CSS class name(s) applied by React during the transition when the ViewTransition activates. It can be a string or an object.
120120

@@ -123,7 +123,7 @@ The View Transition Class is the CSS class name(s) applied by React during the t
123123

124124
The value `'none'` can be used to prevent a View Transition from activating for a specific trigger.
125125

126-
### Styling View Transitions {/* styling-view-transitions */}
126+
### Styling View Transitions {/*styling-view-transitions*/}
127127

128128
<Note>
129129

@@ -152,7 +152,7 @@ When the `<ViewTransition>` activates an "enter" animation, React will add the c
152152

153153
In the future, CSS libraries may add built-in animations using View Transition Classes to make this easier to use.
154154

155-
#### Caveats {/* caveats */}
155+
#### Caveats {/*caveats*/}
156156

157157
- By default, `setState` updates immediately and does not activate `<ViewTransition>`, only updates wrapped in a [Transition](/reference/react/useTransition). You can also use [`<Suspense>`](/reference/react/Suspense) to opt-in to a Transition to [reveal content](/reference/react/Suspense#revealing-content-together-at-once).
158158
- `<ViewTransition>` creates an image that can be moved around, scaled and cross-faded. Unlike Layout Animations you may have seen in React Native or Motion, this means that not every individual Element inside of it animates its position. This can lead to better performance and a more continuous feeling, smooth animation compared to animating every individual piece. However, it can also lose continuity in things that should be moving by themselves. So you might have to add more `<ViewTransition>` boundaries manually as a result.
@@ -161,9 +161,9 @@ In the future, CSS libraries may add built-in animations using View Transition C
161161

162162
---
163163

164-
## Usage {/* usage */}
164+
## Usage {/*usage*/}
165165

166-
### Animating an element on enter/exit {/* animating-an-element-on-enter */}
166+
### Animating an element on enter/exit {/*animating-an-element-on-enter*/}
167167

168168
Enter/Exit Transitions trigger when a `<ViewTransition>` is added or removed by a component in a transition:
169169

@@ -368,7 +368,7 @@ function Component() {
368368

369369
---
370370

371-
### Animating a shared element {/* animating-a-shared-element */}
371+
### Animating a shared element {/*animating-a-shared-element*/}
372372

373373
Normally, we don't recommend assigning a name to a `<ViewTransition>` and instead let React assign it an automatic name. The reason you might want to assign a name is to animate between completely different components when one tree unmounts and another tree mounts at the same time. To preserve continuity.
374374

@@ -613,7 +613,7 @@ import {MY_NAME} from './shared-name';
613613

614614
---
615615

616-
### Animating reorder of items in a list {/* animating-reorder-of-items-in-a-list */}
616+
### Animating reorder of items in a list {/*animating-reorder-of-items-in-a-list*/}
617617

618618
```js
619619
items.map((item) => <Component key={item.id} item={item} />);
@@ -1041,7 +1041,7 @@ It's important to properly use keys to preserve identity when reordering lists.
10411041

10421042
---
10431043

1044-
### Animating from Suspense content {/* animating-from-suspense-content */}
1044+
### Animating from Suspense content {/*animating-from-suspense-content*/}
10451045

10461046
Just like any Transition, React waits for data and new CSS (`<link rel="stylesheet" precedence="...">`) before running the animation. In addition to this, ViewTransitions also wait up to 500ms for new fonts to load before starting the animation to avoid them flickering in later. For the same reason, an image wrapped in ViewTransition will wait for the image to load.
10471047

@@ -1299,7 +1299,7 @@ You can achieve different effects depending on where you choose to place the `<V
12991299

13001300
---
13011301

1302-
### Opting-out of an animation {/* opting-out-of-an-animation */}
1302+
### Opting-out of an animation {/*opting-out-of-an-animation*/}
13031303

13041304
Sometimes you're wrapping a large existing component, like a whole page, and you want to animate some updates, such as changing the theme. However, you don't want it to opt-in all updates inside the whole page to cross-fade when they're updating. Especially if you're incrementally adding more animations.
13051305

@@ -1317,7 +1317,7 @@ This will only animate if the theme changes and not if only the children update.
13171317

13181318
---
13191319

1320-
### Customizing animations {/* customizing-animations */}
1320+
### Customizing animations {/*customizing-animations*/}
13211321

13221322
By default, `<ViewTransition>` includes the default cross-fade from the browser.
13231323

@@ -1762,7 +1762,7 @@ button:hover {
17621762

17631763
</Sandpack>
17641764

1765-
### Customizing animations with types {/* customizing-animations-with-types */}
1765+
### Customizing animations with types {/*customizing-animations-with-types*/}
17661766

17671767
You can use the [`addTransitionType`](/reference/react/addTransitionType) API to add a class name to the child elements when a specific transition type is activated for a specific activation trigger. This allows you to customize the animation for each type of transition.
17681768

@@ -2091,7 +2091,7 @@ button:hover {
20912091

20922092
---
20932093

2094-
### Animating imperatively with callbacks {/* animating-imperatively-with-callbacks */}
2094+
### Animating imperatively with callbacks {/*animating-imperatively-with-callbacks*/}
20952095

20962096
While [View Transition Classes](#view-transition-class) let you define animations with CSS, sometimes you need imperative control over the animation. The `onEnter`, `onExit`, `onUpdate`, and `onShare` callbacks give you direct access to the view transition pseudo-elements so you can animate them using the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API).
20972097

@@ -2320,15 +2320,15 @@ onEnter={(instance, types) => {
23202320

23212321
---
23222322

2323-
### Building View Transition enabled routers {/* building-view-transition-enabled-routers */}
2323+
### Building View Transition enabled routers {/*building-view-transition-enabled-routers*/}
23242324

23252325
React waits for any pending Navigation to finish to ensure that scroll restoration happens within the animation. If the Navigation is blocked on React, your router must unblock in `useLayoutEffect` since `useEffect` would lead to a deadlock.
23262326

23272327
If a `startTransition` is started from the legacy popstate event, such as during a "back"-navigation then it must finish synchronously to ensure scroll and form restoration works correctly. This is in conflict with running a View Transition animation. Therefore, React will skip animations from popstate. Therefore animations won't run for the back button. You can fix this by upgrading your router to use the Navigation API.
23282328

23292329
---
23302330

2331-
## Troubleshooting {/* troubleshooting */}
2331+
## Troubleshooting {/*troubleshooting*/}
23322332

23332333
### My `<ViewTransition>` is not activating {/* my-viewtransition-is-not-activating */}
23342334

0 commit comments

Comments
 (0)