https://github.com/francescozoccheddu/android-animatorhelpers
Animator helpers for Android and Kotlin
https://github.com/francescozoccheddu/android-animatorhelpers
android-animation android-library android-utils
Last synced: over 1 year ago
JSON representation
Animator helpers for Android and Kotlin
- Host: GitHub
- URL: https://github.com/francescozoccheddu/android-animatorhelpers
- Owner: francescozoccheddu
- License: mit
- Created: 2019-07-28T14:16:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-10T20:02:46.000Z (over 2 years ago)
- Last Synced: 2025-01-18T17:48:43.956Z (over 1 year ago)
- Topics: android-animation, android-library, android-utils
- Language: Kotlin
- Homepage:
- Size: 98.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Animator helpers for Android and Kotlin
## Installation
``` gradle
implementation 'com.francescozoccheddu.animatorhelpers:AnimatorHelpers:0.1'
```
## Examples
### Delegated property
Setup
``` kotlin
var myAnimatedFloat by ABFloat(0f).apply {
onUpdate = {
println("myAnimatedFloat=$it")
}
speed = 3f
}
```
Change value
``` kotlin
myAnimatedFloat = 8f
```
### Standalone object
Setup
``` kotlin
val myAnimatedColor = ABColor(Color.RED).apply {
onUpdate = {
println("myAnimatedColor=#${Integer.toHexString(it)}")
}
duration = 0.5f
}
```
Change value
``` kotlin
myAnimatedColor.value = Color.YELLOW
```
## Classes
- *`AnimatedValue`*
- `UnanimatedValue`
- *`TargetedValue`*
- *`ABValue`*
- `ABColor`
- `ABFloat`
- `ABInt`
- *`SmoothValue`*
- `SmoothColor`
- `SmoothFloat`
- `SmoothInt`
- *`SpringValue`*
- `SpringColor`
- `SpringFloat`
- `SpringInt`
### `AnimatedValue`
Base class
- **`value`** : `Type`
`get` animated value / `set` target value
- **`running`** : `Boolean`
`get` whether animation is running or finished
- **`onUpdate`** : `((ReadOnlyObservableAnimatedValue) -> Unit)?`
`get` / `set` value update callback
- **`reach()`** : `Unit`
end animation and instantly jump to target value
### `TargetedValue`
Animated value with target
- **`target`** : `Type`
`get` target value (`set` by **`value`** property)
### `ABValue`
Android `ValueAnimator` wrapper
Use it for transitions or uninterruptible animations
- **`interpolator`** : `TimeInterpolator`
`get` / `set` value easing
- **`durationMode`** : `ABValue.DurationMode`
`get` duration mode (`set` by **`speed`** or **`duration`** properties)
- **`duration`** : `Float`
`get` / `set` constant animation duration (seconds)
- **`speed`** : `Float`
`get` / `set` constant animation speed (amount per second)
### `SmoothValue`
Continuous exponential animator
Use it for continuously changing target values (eg. to smooth touch drag gestures)
- **`smoothness`** : `Float`
`get` / `set` smoothness amount (`0.2f` is a reasonable value)
### `SpringValue`
Continuous spring animator
Use it for frequently changing target values (eg. to programmatically move on screen objects)
- **`acceleration`** : `Float`
`get` / `set` acceleration amount (velocity increment per second)
- **`maxVelocity`** : `Float`
`get` / `set` velocity limit (amount per second)