系统:修复label滚动速度问题
authorCaisking <3449750381@qq.com>
Wed, 9 Oct 2024 02:24:36 +0000 (10:24 +0800)
committerCaisking <3449750381@qq.com>
Wed, 9 Oct 2024 02:24:36 +0000 (10:24 +0800)
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp

index 06492f4..b6ee295 100755 (executable)
@@ -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;