diff --git a/frameworks/src/core/components/component.cpp b/frameworks/src/core/components/component.cpp index bf7b67ba417ff71681439af2bc65d4e365ddb68f..84b7962b39f3f4fc1df57f70ff96d12ea215b496 100644 --- a/frameworks/src/core/components/component.cpp +++ b/frameworks/src/core/components/component.cpp @@ -862,6 +862,65 @@ void Component::SetAnimationKeyFrames(int16_t keyId, int32_t valueFrom, int32_t } } +void Component::SetAnimationDuration(const AppStyleItem *styleItem, const char *strValue) +{ + if (!IsStyleValueTypeString(styleItem)) { + HILOG_ERROR(HILOG_MODULE_ACE, "style animation during value is invalid!"); + return; + } + trans_->during = ParseToMilliseconds(strValue); +} + +void Component::SetAnimationTimingFunction(const char *strValue, size_t strLen) +{ + uint16_t animationTimingKeyId = KeyParser::ParseKeyId(strValue, strLen); + switch (animationTimingKeyId) { + case K_EASE_IN: + trans_->easing = EasingType::EASE_IN; + break; + case K_EASE_OUT: + trans_->easing = EasingType::EASE_OUT; + break; + case K_EASE_IN_OUT: + trans_->easing = EasingType::EASE_IN_OUT; + break; + default: + trans_->easing = EasingType::LINEAR; + break; + } +} + +void Component::SetAnimationFillMode(const char *strValue, size_t strLen) +{ + uint16_t animationFillKeyId = KeyParser::ParseKeyId(strValue, strLen); + switch (animationFillKeyId) { + case K_FORWARDS: + trans_->fill = OptionsFill::FORWARDS; + break; + default: + trans_->fill = OptionsFill::FNONE; + break; + } +} + +void Component::SetAnimationDelay(const AppStyleItem *styleItem, const char *strValue) +{ + if (!IsStyleValueTypeString(styleItem)) { + HILOG_ERROR(HILOG_MODULE_ACE, "style animation delay value is invalid!"); + return; + } + trans_->delay = ParseToMilliseconds(strValue); +} + +void Component::SetAnimationIterationCount(const AppStyleItem *styleItem, const char *strValue) +{ + if (!IsStyleValueTypeString(styleItem)) { + HILOG_ERROR(HILOG_MODULE_ACE, "style iteration count value is invalid!"); + return; + } + trans_->iterations = TransitionImpl::GetNumIterations(strValue); +} + void Component::SetAnimationStyle(const UIView &view, const AppStyleItem *styleItem, const int16_t keyId) { // special for "animation-iteration-count" which value could be a number or string "infinite" @@ -885,57 +944,23 @@ void Component::SetAnimationStyle(const UIView &view, const AppStyleItem *styleI } switch (keyId) { case K_ANIMATION_DURATION: { - if (!IsStyleValueTypeString(styleItem)) { - HILOG_ERROR(HILOG_MODULE_ACE, "style animation during value is invalid!"); - return; - } - trans_->during = ParseToMilliseconds(strValue); + SetAnimationDuration(styleItem, strValue); break; } case K_ANIMATION_TIMING_FUNCTION: { - uint16_t animationTimingKeyId = KeyParser::ParseKeyId(strValue, strLen); - switch (animationTimingKeyId) { - case K_EASE_IN: - trans_->easing = EasingType::EASE_IN; - break; - case K_EASE_OUT: - trans_->easing = EasingType::EASE_OUT; - break; - case K_EASE_IN_OUT: - trans_->easing = EasingType::EASE_IN_OUT; - break; - default: - trans_->easing = EasingType::LINEAR; - break; - } + SetAnimationTimingFunction(strValue, strLen); break; } case K_ANIMATION_FILL_MODE: { - uint16_t animationFillKeyId = KeyParser::ParseKeyId(strValue, strLen); - switch (animationFillKeyId) { - case K_FORWARDS: - trans_->fill = OptionsFill::FORWARDS; - break; - default: - trans_->fill = OptionsFill::FNONE; - break; - } + SetAnimationFillMode(strValue, strLen); break; } case K_ANIMATION_DELAY: { - if (!IsStyleValueTypeString(styleItem)) { - HILOG_ERROR(HILOG_MODULE_ACE, "style animation delay value is invalid!"); - return; - } - trans_->delay = ParseToMilliseconds(strValue); + SetAnimationDelay(styleItem, strValue); break; } case K_ANIMATION_ITERATION_COUNT: { - if (!IsStyleValueTypeString(styleItem)) { - HILOG_ERROR(HILOG_MODULE_ACE, "style iteration count value is invalid!"); - return; - } - trans_->iterations = TransitionImpl::GetNumIterations(strValue); + SetAnimationIterationCount(styleItem, strValue); break; } default: @@ -1653,6 +1678,7 @@ void Component::AppendIfDescriptor(Component *parent, const jerry_value_t descri DescriptorUtils::DelIfDescriptorRendered(descriptor); } } + void Component::AppendForDescriptor(Component *parent, const jerry_value_t descriptor) { JSValue descriptorOrelements = DescriptorUtils::GetDescriptorRendered(descriptor); @@ -1666,6 +1692,7 @@ void Component::AppendForDescriptor(Component *parent, const jerry_value_t descr AppendDescriptorOrElements(parent, descriptorOrelements); } } + void Component::AppendElement(Component *parent, const jerry_value_t element) { if (parent == nullptr) { diff --git a/frameworks/src/core/components/component.h b/frameworks/src/core/components/component.h index 727bb354f0027a93d0c919dd4813f60ac98de311..7194fd7a8c74f17984cdda61a9e09b8a92d0d1d3 100644 --- a/frameworks/src/core/components/component.h +++ b/frameworks/src/core/components/component.h @@ -593,6 +593,16 @@ private: */ void RemoveAllChildren(); + void SetAnimationDuration(const AppStyleItem *styleItem, const char *strValue); + + void SetAnimationTimingFunction(const char *strValue, size_t strLen); + + void SetAnimationFillMode(const char *strValue, size_t strLen); + + void SetAnimationDelay(const AppStyleItem *styleItem, const char *strValue); + + void SetAnimationIterationCount(const AppStyleItem *styleItem, const char *strValue); + /** * @brief childHead_ the child list */