Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation 时支持自定义贝塞尔曲线 timingFunction #785

Merged
merged 2 commits into from
Aug 29, 2021
Merged

Animation 时支持自定义贝塞尔曲线 timingFunction #785

merged 2 commits into from
Aug 29, 2021

Conversation

zcfan
Copy link
Contributor

@zcfan zcfan commented May 30, 2021

之前提过一个 issue,周末有空自己看了下 #632

这是个 prove of concept,仅对 iOS 做了简单的验证,效果如视频,Android 要晚些才有空检查实现是不是正确。

2021-05-30.4.27.15.mov

timingFunction 如下:

this.horizonAnimation = new Animation({
  startValue: 150,
  toValue: 20,
  duration: 1000,
  delay: 500,
  mode: 'timing',
  timingFunction: 'cubic-bezier(.64,1.82,.67,.71)',  // <------------- spring 效果的自定义贝塞尔曲线
  repeatCount: 'loop',
});

新属性叫 cubic-bezier 有两个考虑:

  1. 不与之前的 ease_bezier 冲突,现有项目可能依赖之前的表现(话说之前的 ease_bezier 为什么用下划线,不和其他的 ease-in 之类的一致用中划线?有特别考虑还是单纯手滑打错了?😂)
  2. 符合 web 开发中对 easing- function 的定义,详见:https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function

请初步评估一下接口设计是否合理,可行的话我再完善实现,补充缺失的 web 端

@codecov-commenter
Copy link

codecov-commenter commented May 30, 2021

Codecov Report

Merging #785 (45e7004) into master (f6717be) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #785   +/-   ##
=======================================
  Coverage   61.35%   61.35%           
=======================================
  Files          29       29           
  Lines        1881     1881           
=======================================
  Hits         1154     1154           
  Misses        727      727           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31504cd...45e7004. Read the comment docs.

@zoomchan-cxj zoomchan-cxj linked an issue Jun 7, 2021 that may be closed by this pull request
@tencent-adm
Copy link
Member

tencent-adm commented Aug 11, 2021

CLA assistant check
All committers have signed the CLA.

@zcfan
Copy link
Contributor Author

zcfan commented Aug 12, 2021

补充了 @hippy/react-web 的支持和文档,验证了 android 上的表现,辛苦 review 下

@zcfan
Copy link
Contributor Author

zcfan commented Aug 18, 2021

Timeline.1.mov

补充 demo

@@ -151,7 +151,7 @@ Animation支持的动画配置包括:
* “ease-in”:使用加速插值器,动画速度将随时间逐渐增加;
* “ease-out”:使用减速插值器,动画速度将随时间逐渐减小;
* “ease-in-out”:使用加减速插值器,动画速度前半段先随时间逐渐增加,后半段速度将逐渐减小;
* “ease_bezier”:暂不支持
* “cubic-bezeir”:使用自定义贝塞尔曲线,与 [css transition-timing-function 的 cubic-bezier](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) 一致
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic-bezeir 拼写错误

@@ -151,7 +151,7 @@ Animation支持的动画配置包括:
* “ease-in”:使用加速插值器,动画速度将随时间逐渐增加;
* “ease-out”:使用减速插值器,动画速度将随时间逐渐减小;
* “ease-in-out”:使用加减速插值器,动画速度前半段先随时间逐渐增加,后半段速度将逐渐减小;
* “ease_bezier”:暂不支持
* “cubic-bezeir”:使用自定义贝塞尔曲线,与 [css transition-timing-function 的 cubic-bezier](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) 一致
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充:最低支持版本 2.9.0

@@ -40,7 +40,7 @@
* `ease-in`:使用加速插值器,动画速度将随时间逐渐增加;
* `ease-out`:使用减速插值器,动画速度将随时间逐渐减小;
* `ease-in-out`:使用加减速插值器,动画速度前半段先随时间逐渐增加,后半段速度将逐渐减小;
* `ease_bezier`:暂不支持
* `cubic-bezeir`:使用自定义贝塞尔曲线,与 [css transition-timing-function 的 cubic-bezier](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) 一致
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic-bezeir 拼写错误,补充最低支持版本

@zoomchan-cxj zoomchan-cxj merged commit ee210f3 into Tencent:master Aug 29, 2021
@zcfan zcfan deleted the feat_cubic-bezier branch August 30, 2021 02:05
zoomchan-cxj added a commit that referenced this pull request Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants