# Backboard **Repository Path**: chinasoft2_ohos/Backboard ## Basic Information - **Project Name**: Backboard - **Description**: 反弹动画框架 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 2 - **Created**: 2021-05-20 - **Last Updated**: 2023-10-26 ## Categories & Tags **Categories**: harmonyos-animate **Tags**: None ## README # Backboard #### 项目介绍 - 项目名称:Backboard - 所属系列:openharmony的第三方组件适配移植 - 功能:一个基于反弹的框架,通过将其与视图和动作耦合,便于开发者更方便的把Component与Motion结合起来使用 - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:Release v0.1.2 #### 效果演示 #### 安装教程 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:Backboard:1.0.0') implementation('com.facebook.rebound:rebound:0.3.8') ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 Backboard顶部反弹动画框架管理Springs,简化了最常见的用例: ``` Actions,such as MotionEvents,are mapped to Springs via Imitators. Springs are mapped to Components and view properties via Performers. ``` 此外,`Actor`包装还包装了上述对象,并提供了一个简单的界面,用于将触摸动作映射到视图的位置拖动。 - Performers `Performer`接受当前`Spring`并将其设置为view属性的值,用法: ``` Spring bounce = SpringSystem.create().createSpring(); Performer xMotion = new Performer(view, View.TRANSLATION_X); bounce.addListener(xMotion); ``` 对于那些节省屏幕空间的用户,可以使用: ``` Spring bounce = SpringSystem.create().createSpring().addListener(new Performer(component, View.TRANSLATION_X)); ``` - Imitating Springs `SpringImitator`也是一个`SpringListener`。当`Spring`它模仿更新时,它更新`Spring`它所控制的最终值,用法: ``` SpringSystem springSystem = SpringSystem.create(); Spring leader = springSystem.createSpring(); Spring follower = springSystem.createSpring(); SpringImitator follow = new SpringImitator(follower); leader.addListener(follow); ``` - Actors 该类通过将每个组件连接在一起进一步简化视图,创建方法: ``` Actor actor = new Actor.Builder(SpringSystem.create(), component) .addTranslateMotion(MotionProperty.X) .addTranslateMotion(MotionProperty.Y) .build(); ``` 也可以提供SpringSystem,Spring,MotionImitator`和`Performer,并将其连接: ``` SpringSystem springSystem = SpringSystem.create(); Spring spring = springSystem.createSpring(); Actor verbose = new Actor.Builder(springSystem, component) .addMotion(spring, new MotionImitator(spring, MotionProperty.X), new Performer(component, View.TRANSLATION_X) .build(); ``` 也可以排除构造的`Performer`和`Spring`出来的`MotionImitator`(使用默认`SpringConfig`),将其连接: ``` Actor walk = new Actor.Builder(SpringSystem.create(), walker) .addMotion(new MotionImitator(MotionProperty.X), new Performer(View.TRANSLATION_X)) .build(); ``` 可以进一步简化为: ``` Actor run = new Actor.Builder(SpringSystem.create(), runner).addMotion(MotionProperty.X, View.TRANSLATION_X).build(); ``` ``` Actor bolt = new Actor.Builder(SpringSystem.create(), bolter).addTranslateMotion(MotionProperty.X).build(); ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.0 #### 版权和许可信息 ``` Copyright 2015-2016 Tumblr, 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. ``` ​