spip232
V2EX  ›  问与答

如何使用 requestAnimationFrame 实现降价效果?

  •  
  •   spip232 · Jul 2, 2018 · 1652 views
  •   You need to sign in to view this topic
    This topic created in 2934 days ago, the information mentioned may be changed or developed.

    123.59 255.76

    列表页面中有多个类似以上形式的的,假设每秒降价 0.1 元,那么 span 内的数字就不断的变小,目前遇到的问题是每次只能实现第一条价格会动起来,后面的都不动,另外一个困扰是,我使用了 settimeout 来不断获取当前时间和 data-starttime 判断降价时间是否开始了,导致 requestAnimationFrame 的动画平率越来越快

    求大神指点

    1 replies    2018-07-02 23:11:11 +08:00
    spip232
        1
    spip232  
    OP
       Jul 2, 2018
    <span class="price" data-price="123.59" data-starttime="1509809876">123.59</span>
    <span class="price" data-price="255.76" data-starttime="1509810123">255.76</span>

    形式如上
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3115 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:13 · PVG 22:13 · LAX 07:13 · JFK 10:13
    ♥ Do have faith in what you're doing.