From: Caisking <3449750381@qq.com> Date: Wed, 9 Oct 2024 02:24:36 +0000 (+0800) Subject: 系统:修复label滚动速度问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=3d31b65d1f700f7eeadc0ca4dbf7bd27eb43611a;p=mirrors%2FFD230.git 系统:修复label滚动速度问题 --- 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;