# ParallaxTarget

# ParallaxTarget

Artifact:[androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback)  
[View Source](https://cs.android.com/search?q=file:androidx/leanback/widget/ParallaxTarget.java+class:androidx.leanback.widget.ParallaxTarget)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget "View this page in Java")

<br />

```
abstract class ParallaxTarget
```

<br />

Known direct subclasses  
[ParallaxTarget.DirectPropertyTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget),[ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget)  

|----------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ParallaxTarget.DirectPropertyTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget)             | DirectPropertyTarget is to support direct mapping into either Integer Property or Float Property.                                                                                                                                                                                                          |
| [ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget) | PropertyValuesHolderTarget is an implementation of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)that uses[PropertyValuesHolder](https://developer.android.com/reference/android/animation/PropertyValuesHolder.html)to update the target object. |

*** ** * ** ***

ParallaxTarget is responsible for updating the target through the[update](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#update(float))method or the[directUpdate](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number))method when[isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping())is true. When[isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping())is false,[ParallaxEffect](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect)transforms the values of[Parallax](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax), which represents the current state of UI, into a float value between 0 and 1. That float value is passed into[update](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#update(float))method.

## Summary

|                                                                                                                                                                                                                                                                                        ### Nested types                                                                                                                                                                                                                                                                                        |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[ParallaxTarget.DirectPropertyTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget)`<T, V : `[Number](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html)`?> : `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget) DirectPropertyTarget is to support direct mapping into either Integer Property or Float Property.                                                                                                                         |
| `class `[ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget)` : `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget) PropertyValuesHolderTarget is an implementation of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)that uses[PropertyValuesHolder](https://developer.android.com/reference/android/animation/PropertyValuesHolder.html)to update the target object. |

|                                                    ### Public constructors                                                    |
|-------------------------------------------------------------------------------------------------------------------------------|
| [ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#ParallaxTarget())`()` |

|                                ### Public functions                                 |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [directUpdate](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number))`(value: `[Number](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html)`!)` Directly update the target using a float or int value.                                                                                                                                            |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping())`()` Returns true if the ParallaxTarget is directly mapping from source value,[directUpdate](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number))will be used to update value, otherwise update(fraction) will be called to update value. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [update](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#update(float))`(fraction: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Implementation class is supposed to update target with the provided fraction (between 0 and 1).                                                                                                                          |

## Public constructors

### ParallaxTarget

Added in 1.1.0  

```
ParallaxTarget()
```  

## Public functions

### directUpdate

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun directUpdate(value: Number!): Unit
```

Directly update the target using a float or int value. Called when[isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping())is true.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|----------------------------|
| `value: `[Number](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html)`!` | Either int or float value. |

|                                                          See also                                                           |
|-----------------------------------------------------------------------------------------------------------------------------|---|
| [isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping()) |   |

### isDirectMapping

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun isDirectMapping(): Boolean
```

Returns true if the ParallaxTarget is directly mapping from source value,[directUpdate](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number))will be used to update value, otherwise update(fraction) will be called to update value. Default implementation returns false.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if direct mapping, false otherwise. |

|                                                               See also                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------|---|
| [directUpdate](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)) |   |
| [update](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#update(float))                        |   |

### update

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun update(fraction: Float): Unit
```

Implementation class is supposed to update target with the provided fraction (between 0 and 1). The fraction represents percentage of completed change (e.g. scroll) on target. Called only when[isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping())is false.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|--------------------------|
| `fraction: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | Fraction between 0 to 1. |

|                                                          See also                                                           |
|-----------------------------------------------------------------------------------------------------------------------------|---|
| [isDirectMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#isDirectMapping()) |   |