mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
parse keybord animation option
Signed-off-by: jiangdayuan <jiangdayuan@huawei.com> Change-Id: Ie2f3f4624662426f0448097a8cdaac99be2b1360
This commit is contained in:
parent
6c8b9d6515
commit
b9d98594be
@ -481,6 +481,39 @@ void AnimationUtil::KeyframesAddKeyFrame(
|
||||
}
|
||||
}
|
||||
|
||||
AnimationOption AnimationUtil::CreateKeyboardAnimationOption(
|
||||
const KeyboardAnimationConfig& config, float keyboardHeight)
|
||||
{
|
||||
static const LinearMapNode<RefPtr<Curve>> curveMap[] = {
|
||||
{ "ease", Curves::EASE },
|
||||
{ "easeIn", Curves::EASE_IN },
|
||||
{ "easeInOut", Curves::EASE_IN_OUT },
|
||||
{ "easeOut", Curves::EASE_OUT },
|
||||
{ "default", Curves::EASE_IN_OUT },
|
||||
{ "linear", Curves::LINEAR },
|
||||
{ "spring", AceType::MakeRefPtr<ResponsiveSpringMotion>(ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_RESPONSE,
|
||||
ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_DAMPING_RATIO,
|
||||
ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_BLEND_DURATION) },
|
||||
{ "interactiveSpring", AceType::MakeRefPtr<ResponsiveSpringMotion>(
|
||||
ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_RESPONSE,
|
||||
ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_DAMPING_RATIO,
|
||||
ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_BLEND_DURATION) },
|
||||
};
|
||||
|
||||
AnimationOption option;
|
||||
NearZero(keyboardHeight) ? option.SetDuration(config.durationOut_) : option.SetDuration(config.durationIn_);
|
||||
RefPtr<Curve> curve;
|
||||
if (config.curveType_ == "cubic" && config.curveParams_.size() == 4) {
|
||||
curve = AceType::MakeRefPtr<CubicCurve>(
|
||||
config.curveParams_[0], config.curveParams_[1], config.curveParams_[2], config.curveParams_[3]);
|
||||
} else {
|
||||
auto index = BinarySearchFindIndex(curveMap, ArraySize(curveMap), config.curveType_.c_str());
|
||||
curve = index < 0 ? nullptr : curveMap[index].value;
|
||||
}
|
||||
option.SetCurve(curve);
|
||||
return option;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void AnimationUtil::AddAnimatable(const T& value, double time, AnimatableType type)
|
||||
{
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
void ParseAnimationStyle(const std::vector<std::unordered_map<std::string, std::string>>& animationKeyframes,
|
||||
const RefPtr<Declaration>& declaration, const RefPtr<ThemeConstants> themeConstants);
|
||||
|
||||
static AnimationOption CreateKeyboardAnimationOption(const KeyboardAnimationConfig& config, float keyboardHeight);
|
||||
|
||||
private:
|
||||
void KeyframesAddKeyFrame(const std::string& keyStyle, const std::string& value, const std::string& timeStr);
|
||||
template<class T>
|
||||
|
@ -2117,12 +2117,9 @@ void PipelineContext::OnVirtualKeyboardHeightChange(
|
||||
}
|
||||
};
|
||||
|
||||
AnimationOption option;
|
||||
NearZero(keyboardHeight) ? option.SetDuration(keyboardAnimationConfig_.durationOut_)
|
||||
: option.SetDuration(keyboardAnimationConfig_.durationIn_);
|
||||
auto curve = MakeRefPtr<CubicCurve>(0.2f, 0.0f, 0.2f, 1.0f); // animation curve: cubic [0.2, 0.0, 0.2, 1.0]
|
||||
AnimationOption option = AnimationUtil::CreateKeyboardAnimationOption(keyboardAnimationConfig_, keyboardHeight);
|
||||
if (rsTransaction) {
|
||||
Animate(option, curve, func);
|
||||
Animate(option, option.GetCurve(), func);
|
||||
} else {
|
||||
func();
|
||||
}
|
||||
|
@ -675,12 +675,9 @@ void PipelineContext::OnVirtualKeyboardHeightChange(
|
||||
}
|
||||
};
|
||||
|
||||
AnimationOption option;
|
||||
NearZero(keyboardHeight) ? option.SetDuration(keyboardAnimationConfig_.durationOut_)
|
||||
: option.SetDuration(keyboardAnimationConfig_.durationIn_);
|
||||
auto curve = MakeRefPtr<CubicCurve>(0.2f, 0.0f, 0.2f, 1.0f); // animation curve: cubic [0.2, 0.0, 0.2, 1.0]
|
||||
AnimationOption option = AnimationUtil::CreateKeyboardAnimationOption(keyboardAnimationConfig_, keyboardHeight);
|
||||
if (rsTransaction) {
|
||||
Animate(option, curve, func);
|
||||
Animate(option, option.GetCurve(), func);
|
||||
} else {
|
||||
func();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ ohos_unittest("pipeline_context_test_ng") {
|
||||
# animation
|
||||
"$ace_root/frameworks/core/animation/animatable_data.cpp",
|
||||
"$ace_root/frameworks/core/animation/animatable_properties.cpp",
|
||||
"$ace_root/frameworks/core/animation/animation_util.cpp",
|
||||
"$ace_root/frameworks/core/animation/anticipate_curve.cpp",
|
||||
"$ace_root/frameworks/core/animation/cubic_curve.cpp",
|
||||
"$ace_root/frameworks/core/animation/curves.cpp",
|
||||
|
Loading…
Reference in New Issue
Block a user