LoginSignup
3
3

More than 5 years have passed since last update.

JavaScript easing

Posted at
easeOutExpo = (t, b, c, d) ->
  if t is d then b + c else c * (-Math.pow(2, -10 * t / d) + 1) + b

now = +new Date

step = ->
  t = +new Date - now # 現在秒 (現在
  b = 0               # 最初の値
  c = 100             # 変動する値
  d = 2000            # 何秒かけて動くか
  v = easeOutExpo(t, b, c, d)
  console.log v
  setTimeout (-> step()), 1000 / 60 if d > t

step()

※ Cの変化量とは
例えば、x1(座標が10)からx2(座標が100)に移動する場合cは90となる。
つまり変化の総量である。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3