【问题标题】:Sync css translation of scrolling text to same speed (but different duration)将滚动文本的 css 翻译同步到相同的速度(但持续时间不同)
【发布时间】:2020-12-22 21:04:11
【问题描述】:

我准备了一个 StackBlitz 应用程序(角度)来展示我的问题。

Application

如您所见,由于文本长度不同,文本以不同的速度移动。 我想要的是动态设置持续时间,以便所有文本动画都具有相同的滚动速度。我目前的计算遗漏了一些东西(或者可能是错误的?),但我无法弄清楚。这可能吗?

【问题讨论】:

    标签: css angular css-animations


    【解决方案1】:

    解决了。 GetDuration 现在看起来像这样:

    getDuration(el: any) {
        const scrollInterval = 25;
        const scrollSpacePx = 1;
        const speed = scrollSpacePx / scrollInterval;
        const durationMs = (el.clientWidth + el.parentElement.clientWidth) / speed;
        const durationSec = durationMs / 1000;
    
        return durationSec.toString() + "s";
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多