RxAnimator
RxAnimator copied to clipboard
An RxJava2 binding for android Animator
RxAnimator
An RxJAva2 binding for android Animator
![Android app on Google Play](https://developer.android.com/images/brand/en_app_rgb_wo_45.png)
Run sequencially
RxAnimator.ofFloat(view, "translationY", 0, 300).animationDuration(500)
.flatMap(anim -> RxAnimator.ofFloat(view, "translationX", 0, 300))
.subscribe(anim -> {});
RxAnimator
contains the same methods as ValueAnimator`
.animationDuration(long)
.animationStartDelay(long)
.animationInterpolator(interpolator)
.animationEvaluator(evaluator)
...
Run in parallel
(Using RxBindings for the click observable)
RxView.clicks(view)
.flatMap(animation ->
Observable.zip(
RxAnimator.ofFloat(view, "scaleX", 5),
RxAnimator.ofFloat(view, "scaleY", 5),
RxAnimator.ofFloat(view, "translationY", 300),
RxAnimator.ofFloat(view, "translationX", 200),
(a, a2, a3, a4) -> a
)
)
.flatMap(animation ->
Observable.zip(
RxAnimator.ofFloat(view, "scaleX", 1),
RxAnimator.ofFloat(view, "scaleY", 1),
RxAnimator.ofFloat(view, "translationX", 0),
RxAnimator.ofFloat(view, "translationY", 0),
(a, a2, a3, a4) -> a
)
)
.subscribe(animation -> {});
Trigger event
By default the observable submits when the animator ends
You can configure it using .animationTriggerEvent(Event.START / Event.END / Event.CANCEL / EVENT.RESTART)
Download
compile 'com.github.florent37:rxanimator:1.0.0'
Credits
Author: Florent Champigny
![Android app on Google Play](https://developer.android.com/images/brand/en_app_rgb_wo_45.png)
![Follow me on Google+](https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/gplus.png)
![Follow me on Twitter](https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/twitter.png)
![Follow me on LinkedIn](https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/linkedin.png)
#License
Copyright 2017 florent37, Inc.
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.