# ohos_additive_animations **Repository Path**: chinasoft4_ohos/ohos_additive_animations ## Basic Information - **Project Name**: ohos_additive_animations - **Description**: 一种简单的方法来添加任何物体的任何属性动画 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-06-28 - **Last Updated**: 2021-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ohos_additive_animations ## 项目介绍 - 项目名称:ohos_additive_animations - 所属系列:openharmony的第三方组件适配移植 - 功能:一种简单的方法来添加任何物体的任何属性动画 - 项目移植状态:主功能完成,Multiple component、Custom drawing on canvas、Chaining animations、Chaining repeated animations原库使用数值转换器实现,ohos暂不支持,还有属性方法的不同,导致效果有差异。 - 调用差异:无 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:Release v1.9.1 ## 效果演示 ## 安装教程 1.在项目根目录下的build.gradle文件中, ``` allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中 ``` dependencies { implementation('com.gitee.chinasoft_ohos:ohos_additive_animations:1.0.0') ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 ## 使用说明 1、简单使用 ``` 监听TouchEvent事件 AdditiveAnimator.animate(mAnimated) .centerX(touchX) .centerY(touchY).setDuration(1000) .start(); 颜色过度 AdditiveAnimatorColor.componentColor(mComponent, starColor, endColor, mAnimation, 1000); 详情请参考demo ``` 2、支持动态设置动画时间及路径绘制 ``` AdditiveAnimator.animate(mComponent).setDuration(3200).setTimeCurveType(Animator.CurveType.LINEAR) .xyRotationAlongPath(path2) .setRepeatCount(AnimatorValue.INFINITE) .start(); ``` 3、支持动画延时时间,多视图相同属性动画 ``` // 为多个视图设置相同属性的动画,而无需循环。 new AdditiveAnimator().target(myView1, myView2).alpha(0).start(); // 为每一个视图动画开启设置延时 new AdditiveAnimator().targets(Arrays.asList(myView1, myView2), 50L).alpha(0).start(); ``` 4、控制显隐 ``` // 直接控制显隐 AdditiveAnimator.animate(view) .fadeVisibility(View.GONE) // fades out the view, then sets visibility to GONE .start(); // 通过淡入淡出效果实现简单的动画效果 AdditiveAnimator.animate(view) // the first param decides whether the view should be GONE or INVISIBLE, // the second one decides how much to move the view as it fades out .visibility(ViewVisibilityAnimation.fadeOutAndTranslateX(true, 100f)) // only move x .visibility(ViewVisibilityAnimation.fadeOutAndTranslateY(true, 100f)) // only move y .visibility(ViewVisibilityAnimation.fadeOutAndTranslate(true, 100f, 100f)) // move x and y .start(); ``` 5、通过then连接块切换视图状态 ``` new AdditiveAnimator() .targets(normalViews) .scale(1f) // normal .then() .target(highlightedView) .scale(1.2f) // highlighted .start(); new AdditiveAnimator() .targets(normalViews) .state(MyViewState.NORMAL) .then() .target(highlightedView) .state(MyViewState.HIGHLIGHTED) .start(); ``` 6、自定义动画属性 ``` new AdditiveRectAnimator().setDuration(1500).setRepeatCount(AnimatorValue.INFINITE) .targets(mRects, delayBetweenAnimations) .size(DpConverter.dip2px(mContext, 70)) .cornerRadius(DpConverter.dip2px(mContext, 60)) .start(); ``` ## 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 ## 版本迭代 - 1.0.0 ## 版权和许可信息 AdditiveAnimator is licensed under the Apache v2 license: ``` Copyright 2021 David Ganster 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.