From 0adabe785152b668ec8c22f7078f3fa914b05bb2 Mon Sep 17 00:00:00 2001 From: tandyyan Date: Thu, 15 Aug 2024 18:28:01 +0800 Subject: [PATCH] feat(ohos): fix animation translate & scale (#132) Co-authored-by: tandyyan --- .../native/src/utils/hr_convert_utils.cc | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/framework/ohos/src/main/cpp/impl/renderer/native/src/utils/hr_convert_utils.cc b/framework/ohos/src/main/cpp/impl/renderer/native/src/utils/hr_convert_utils.cc index 40e9ab36372..eec14aee258 100644 --- a/framework/ohos/src/main/cpp/impl/renderer/native/src/utils/hr_convert_utils.cc +++ b/framework/ohos/src/main/cpp/impl/renderer/native/src/utils/hr_convert_utils.cc @@ -133,17 +133,25 @@ bool HRConvertUtils::TransformToArk(HippyValueArrayType &valueArray, HRTransform if (!it.second.ToDouble(value)) { continue; } - HRScale scale; - scale.x = static_cast(value); - transform.scale = scale; + if (transform.scale) { + transform.scale->x = static_cast(value); + } else { + HRScale scale; + scale.x = static_cast(value); + transform.scale = scale; + } } else if (it.first == "scaleY") { double value = 0; if (!it.second.ToDouble(value)) { continue; } - HRScale scale; - scale.y = static_cast(value); - transform.scale = scale; + if (transform.scale) { + transform.scale->y = static_cast(value); + } else { + HRScale scale; + scale.y = static_cast(value); + transform.scale = scale; + } } else if (it.first == "translate") { HippyValueArrayType array; if (!it.second.IsArray() || !it.second.ToArray(array)) { @@ -174,17 +182,25 @@ bool HRConvertUtils::TransformToArk(HippyValueArrayType &valueArray, HRTransform if (!it.second.ToDouble(value)) { continue; } - HRTranslate translate; - translate.x = static_cast(value); - transform.translate = translate; + if (transform.translate) { + transform.translate->x = static_cast(value); + } else { + HRTranslate translate; + translate.x = static_cast(value); + transform.translate = translate; + } } else if (it.first == "translateY") { double value = 0; if (!it.second.ToDouble(value)) { continue; } - HRTranslate translate; - translate.y = static_cast(value); - transform.translate = translate; + if (transform.translate) { + transform.translate->y = static_cast(value); + } else { + HRTranslate translate; + translate.y = static_cast(value); + transform.translate = translate; + } } else if (it.first == "skewX") { } else if (it.first == "skewY") { } else {