Configurable icon animation wrapper.
Add Jitpack to your root build.gradle
file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
Add dependency to application build.gradle
file, where x.y.z
is the latest release version:
implementation "com.github.ChiliLabs:FireLike:x.y.z"
Emitted icon animation is designed to be highly configurable while keeping the API as simple as possible. Each created icon is animated on it's own by calling the value providers in the configuration.
- Create
IconEmitterManager
in your activity or fragment (or any other UI controller). It requires rootViewGroup
of current layout and configuration instance.
private lateinit var iconEmitter: IconEmitterManager
// In onCreate()
iconEmitter = IconEmitterManager(
root = sample_root,
config = IconEmitterConfig(
iconResource = R.drawable.ic_thumb_blue,
interpolatorProvider = ... ,
durationProvider = ... ,
translationYProvider = ... ,
translationXProvider = ... ,
scaleValueProvider = ... ,
alphaValueProvider = ...
)
)
- After view is inflated and drawn simply call
iconEmitter.emitIconFromView(view)
whereview
is the starting place of the new flying icon.
-
Icon Resource - resource id that will be used to draw each icon.
-
InterpolatorProvider
- returns an interpolator that is applied to all animations on single icon, may be different for different icons. More options -
DurationValueProvider
- returns an amount of milliseconds that the animation will be played. More options -
TranslationValueProvider
for X and Y axis - returns an array of key positions of the the icon on the respective axis beginning from position of view provided tolikeManager.addLikeFromView(view)
. More options -
ScaleValueProvider
- returns a relative scale where1.0f
equals no change,0.5f
equals to icon with half of original width and height, etc. More options -
AlphaValueProvider
- returns a value between0.0f
and1.0f
where 0 - completly transparent and 1 - no transparancy. More options
-
Few predefined configs are available in
DefaultConfigs
object. Those pre0defined configs could be easily adjusted usingconfig.copy()
or used as a reference for custom implementation. -
None of the built-in providers are dependant on time, but such features could be implemented using custom value providers.
-
Animation values are pre-computed, therefore it is not possible to change animations after it has been started.
-
Library is written in Kotlin for Kotlin so usage from Java, whle absolutely possible, might not be as straight-forward.
-
Minimal SDK is 19
-
Currently only single icon resource is supported.
Copyright 2018 Chili Labs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.