6 Star 4 Fork 2

HarmonyOS-TPC / AnimationEasingFunctions

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

AnimationEasingFunctions

目录

功能介绍

  • ohos动画缓动功能。让动画更逼真! 实现下列多种动画运动轨迹
  • BackEaseIn
  • BackEaseOut
  • BackEaseInOut
  • BounceEaseIn
  • BounceEaseOut
  • BounceEaseInOut
  • CircEaseIn
  • CircEaseOut
  • CircEaseInOut
  • CubicEaseIn
  • CubicEaseOut
  • CubicEaseInOut
  • ElasticEaseIn
  • ElasticEaseInOut
  • ElasticEaseOut
  • ExpoEaseIn
  • ExpoEaseOut
  • ExpoEaseInOut
  • QuadEaseIn
  • QuadEaseOut
  • QuadEaseInOut
  • QuintEaseIn
  • QuintEaseOut
  • QuintEaseInOut
  • SineEaseIn
  • SineEaseOut
  • SineEaseInOut
  • Linear

演示

缓动动画 缓动动画

集成

方式一:
将项目中的build.gradle文件中dependencies→classpath版本改为对应的版本(即你的IDE新建项目中所用的版本)
添加har到entry下的libs文件夹内
entry的build.gradle内添加如下代码
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])


方式二:
allprojects{
    repositories{
        mavenCentral()
    }
}
implementation 'io.openharmony.tpc.thirdlib:AnimationEasingFunctions:1.0.2' 

使用示例

    private ListContainer mEasingList;
    private EasingAdapter mAdapter;
    private Component mTarget;
    private long mDuration = 2000;
    private DrawView mHistory;

        mEasingList = (ListContainer) findComponentById(ResourceTable.Id_easing_list);
        mAdapter = new EasingAdapter(this);
        mEasingList.setItemProvider(mAdapter);
        mTarget = findComponentById(ResourceTable.Id_target);
        mHistory = (DrawView) findComponentById(ResourceTable.Id_history);
        mEasingList.setItemClickedListener(new ListContainer.ItemClickedListener() {
            @Override
            public void onItemClicked(ListContainer listContainer, Component component, int position, long var4) {
                mHistory.clear();
                Skill skill = (Skill) component.getTag();
                // 动画集合
                AnimatorGroup set = new AnimatorGroup();
                mTarget.setTranslationX(0);
                mTarget.setTranslationY(0);
                // 数值动画
                AnimatorValue animator = new AnimatorValue();
                animator.setDuration(mDuration);
                BaseEasingMethod easing = skill.getMethod(mDuration);
                // 画最开始的点
                mHistory.drawPoint(0, mDuration, 0 - vpToPixels(getContext(), 60));
                set.runSerially(
                        Glider.glide(skill, mDuration, animator,new AnimatorValue.ValueUpdateListener() {
                    @Override
                    public void onUpdate(AnimatorValue animatorValue, float value) {

                        float start = 0;
                        float end = -vpToPixels(getContext(), 157) ;
                        float result = easing.evaluate(value, start, end);
                        mTarget.setTranslationY(result);
                        mHistory.drawPoint(mDuration * value, mDuration, result - vpToPixels(getContext(), 60));
                    }
                }));
                set.setDuration(mDuration);
                set.start();
            }
        });

接口说明


     /**
     * 设置动画
     *
     * @param skill   动画方式
     * @param duration 时长
     * @param animator   数值动画
     * @param valueUpdateListener   动画监听器
     * @return 动画对象
     */
    public static AnimatorValue glide(
            Skill skill,
            float duration,
            AnimatorValue animator,
            AnimatorValue.ValueUpdateListener valueUpdateListener)

     /**
     * 设置动画
     *
     * @param skill   动画方式
     * @param duration 时长
     * @param animator   数值动画
     * @return 动画对象
     */
    public static AnimatorValue glide(
            Skill skill,
            float duration,
            AnimatorValue animator)

      /**
      * 控制动画表达式
      *
      * @param duration 时长
      * @return BaseEasingMethod
      */
     public BaseEasingMethod getMethod(float duration)

    /**
     * 获得动画结果
     *
     * @param fraction 动画完成度
     * @param startValue 动画开始位置
     * @param endValue 动画结束位置
     * @return 动画结果
     */
    public final Float evaluate(float fraction, Float startValue, Float endValue)
The MIT License (MIT) Copyright (c) 2017 daimajia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

ohos动画缓动功能。让动画更逼真 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/HarmonyOS-tpc/AnimationEasingFunctions.git
git@gitee.com:HarmonyOS-tpc/AnimationEasingFunctions.git
HarmonyOS-tpc
AnimationEasingFunctions
AnimationEasingFunctions
master

搜索帮助