# ParallaxAnimation

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-behaviors-animations/struct-parallaxanimation/

**struct** · [`ferroui-xaml-behaviors-animations`](/docs/0.5.0/api/ferroui-xaml-behaviors-animations/) · v0.5.0

```rust
struct ParallaxAnimation
```

Applies composition-based parallax offsets without requiring a behavior.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Behaviors.Animations/composition/parallax_animation.rs#L10)

## Members

- [`calculate_offset`](#function-calculate_offset)
- [`try_create`](#function-try_create)
- [`apply`](#function-apply)
- [`apply_to`](#function-apply_to)

<a id="function-calculate_offset"></a>

### calculate_offset

```rust
fn calculate_offset(scroll_offset: Vector, parallax_ratio: f64) -> Vector3
```

Calculates the composition offset for a scroll offset and parallax ratio (the proportion
of the scroll offset to apply). Returns the parallax delta to add to the target's layout
offset.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Behaviors.Animations/composition/parallax_animation.rs#L23)

<a id="function-try_create"></a>

### try_create

```rust
fn try_create(target: Option<&Control>) -> Option<ParallaxAnimation>
```

Creates a parallax animation session that retains the target's composition visual, or
`None` when the target visual is unavailable.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Behaviors.Animations/composition/parallax_animation.rs#L29)

<a id="function-apply"></a>

### apply

```rust
fn apply(self: &Self, scroll_offset: Vector, parallax_ratio: f64)
```

Applies a calculated parallax offset to the retained composition visual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Behaviors.Animations/composition/parallax_animation.rs#L36)

<a id="function-apply_to"></a>

### apply_to

```rust
fn apply_to(target: Option<&Control>, scroll_offset: Vector, parallax_ratio: f64) -> bool
```

Applies a calculated parallax offset to a control's composition visual. Returns `true`
when a composition visual was updated; otherwise, `false`.

Deviation (DEVIATIONS.md, Behaviors): the static `Apply(Control, Vector, double)` overload
of the reference; Rust has no overloads.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Behaviors.Animations/composition/parallax_animation.rs#L47)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
