From 3d31b65d1f700f7eeadc0ca4dbf7bd27eb43611a Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Wed, 9 Oct 2024 10:24:36 +0800 Subject: [PATCH] =?utf8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9A=E4=BF=AE=E5=A4=8Dlab?= =?utf8?q?el=E6=BB=9A=E5=8A=A8=E9=80=9F=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../services/gui/uikit/ui/frameworks/components/ui_label.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp index 06492f4a4..b6ee2957f 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp @@ -18,6 +18,7 @@ #include "font/ui_font.h" #include "gfx_utils/graphic_log.h" #include "themes/theme_manager.h" +#include "cmath" namespace OHOS { class LabelAnimator : public Animator, public AnimatorCallback { @@ -136,14 +137,14 @@ private: uint32_t time = HALTick::GetInstance().GetElapseTime(startTime_); float x0 = startPos_; float x1 = 1.0 * labelWidth_ - textWidth_; -#if 0 +#if 1 float factor = 1000; // 1000: slow down the speed float v = speed_ / factor; v = x1 - x0 > 0 ? v : -v; float t = time; float t1 = (x1 - x0) / v; float period = 2.0 * t1; // 2: double - t = t - float(t / period) * period; + t = t - floorf(t / period) * period; float x = 0; if (t < t1) { x = v * t + x0; -- 2.17.1