Skip to content

Commit

Permalink
docs: move-around copy
Browse files Browse the repository at this point in the history
  • Loading branch information
patrycjakalinska committed Jul 16, 2024
1 parent dfce6a1 commit 848391a
Showing 1 changed file with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,36 @@ function App() {
}
```

<details>
<summary>Type definitions</summary>

```typescript
class Keyframe {
constructor(definitions: Record<string, KeyframeProps>);
duration(durationMs: number): Keyframe;
delay(delayMs: number): Keyframe;
reduceMotion(reduceMotionV: ReduceMotion): Keyframe;
withCallback(callback: (finished: boolean) => void): Keyframe;
}
```

</details>

### Arguments

#### `definitions`

An object, passed as a first argument that contains definitions of your animation.
An object, that contains definitions of your animation.
The object keys should be within range `0-100` and correspond to animation progress.
The object values should consist of style props and/or [easing](/docs/animations/withTiming/#easing) function. If easing property is not provided, it defaults to `Easing.linear`.
The object values should consist of style props and/or [easing function](/docs/animations/withTiming/#easing). If easing property is not provided, it defaults to `Easing.linear`.

The keys take the following values:

- `0` or `from`: Initial state of the object.
- Middle points (e.g., `45`): Intermediate states of the object.
- `100` or `to`: Final state of the object.

To `0` assign the style, you want for your object at the beginning of the animation and to `100` assign the style you want for your object to have at the end of the animation.

## Remarks

- Providing keyframe `0` or `from` is required as it contains the initial state of the object you want to animate.
- Ensure you provide the initial value for all style properties you want to animate in other keyframes.
- Do not provide both `0` and `from`, or `100` and `to` keyframes, as it will result in a parsing conflict.
- If you want to animate transform style, make sure that all properties in the transformation array are in the same order in all keyframes.
The key `0` (or `from`) should be assigned the style that you want for your object at the beginning of the animation. The key `100` (or `to`) should be assigned the style that you want for your object at the end of the animation.

## Modifiers

Expand All @@ -70,6 +80,13 @@ keyframe
- `.reduceMotion(reduceMotion: ReduceMotion)` determines how the animation responds to the device's reduced motion accessibility setting.
- `.withCallback(callback: (finished: boolean) => void)` is the callback that will fire after the animation ends. Sets `finished` to `true` when animation ends without interruptions, and `false` otherwise.

## Remarks

- Providing keyframe `0` or `from` is required as it contains the initial state of the object you want to animate.
- Ensure you provide the initial value for all style properties you want to animate in other keyframes.
- Do not provide both `0` and `from`, or `100` and `to` keyframes, as it will result in a parsing conflict.
- If you want to animate transform style, make sure that all properties in the transformation array are in the same order in all keyframes.

## Example

<InteractiveExample src={KeyframeSrc} component={Keyframe} />
Expand Down

0 comments on commit 848391a

Please sign in to comment.