# ParallaxBehavior

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-interactions-custom/struct-parallaxbehavior/

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

```rust
struct ParallaxBehavior
```

A behavior that moves the associated element at a different speed than the scrolling
container, creating a parallax effect.

Deviation (DEVIATIONS.md, Behaviors): the reference implements `IObserver<Vector>` and
subscribes itself to the offset of the scroll viewer; here the subscription is a closure that
calls `on_next`, and `on_error` and
`on_completed` are plain members (the class does not implement the
observer contract, an object of the class model is not shared as an `Rc`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L24)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`source_scroll_viewer_property`](#function-source_scroll_viewer_property)
- [`parallax_ratio_property`](#function-parallax_ratio_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`source_scroll_viewer`](#function-source_scroll_viewer)
- [`set_source_scroll_viewer`](#function-set_source_scroll_viewer)
- [`parallax_ratio`](#function-parallax_ratio)
- [`set_parallax_ratio`](#function-set_parallax_ratio)
- [`on_completed`](#function-on_completed)
- [`on_error`](#function-on_error)
- [`on_next`](#function-on_next)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L30)

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<ParallaxBehavior>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L30)

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

### source_scroll_viewer_property

```rust
fn source_scroll_viewer_property() -> &'static StyledProperty<Option<ElementRef<ScrollViewer>>>
```

Identifies the `SourceScrollViewer` property.

Deviation (DEVIATIONS.md, Behaviors): the behavior does not own the scroll viewer, so
the value is an element reference.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L41)

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

### parallax_ratio_property

```rust
fn parallax_ratio_property() -> &'static StyledProperty<f64>
```

Identifies the `ParallaxRatio` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L41)

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

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L108)

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

### new

```rust
fn new() -> Ref<Self>
```

Creates a behavior.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L117)

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

### source_scroll_viewer

```rust
fn source_scroll_viewer(self: &Self) -> Option<Ref<ScrollViewer>>
```

Gets or sets the source scroll viewer. If not set, the behavior will attempt to find a
parent scroll viewer. Markup resolves a name given for it to the named element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L123)

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

### set_source_scroll_viewer

```rust
fn set_source_scroll_viewer(self: &Self, value: impl Into<Nullable<ScrollViewer>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L127)

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

### parallax_ratio

```rust
fn parallax_ratio(self: &Self) -> f64
```

Gets or sets the parallax ratio.
0.0 means no movement (static).
1.0 means moves with scroll (normal).
Values between 0 and 1 create a "far away" depth effect.
Negative values move in reverse.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L136)

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

### set_parallax_ratio

```rust
fn set_parallax_ratio(self: &Self, value: f64)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L140)

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

### on_completed

```rust
fn on_completed(self: &Self)
```

Notifies the behavior that the offset observable completed (`IObserver.OnCompleted`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L145)

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

### on_error

```rust
fn on_error(self: &Self, _error: ObservableError)
```

Notifies the behavior that the offset observable failed (`IObserver.OnError`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L148)

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

### on_next

```rust
fn on_next(self: &Self, value: Vector)
```

Applies the parallax offset for the scroll offset `value` (`IObserver.OnNext`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions.Custom/composition/parallax_behavior.rs#L151)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`BehaviorImplExt`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-behaviorimplext/)
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ParallaxBehavior>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`BehaviorImpl`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-behaviorimpl/)

## Availability

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