一个具体的例子,
假设我们的初始值为1000,我们希望在3s内达到400:
var initialValue = 1000,
destinationValue = 400,
amountOfChange = destinationValue - initialValue, // = -600
duration = 3,
elapsed;
让我们从 0 到 3:
elapsed = 0
$.easing.easeInQuad(null, elapsed, initialValue, amountOfChange, duration)
//> 1000
elapsed = 1
$.easing.easeInQuad(null, elapsed, initialValue, amountOfChange, duration)
//> 933.3333333333334
elapsed = 2
$.easing.easeInQuad(null, elapsed, initialValue, amountOfChange, duration)
//> 733.3333333333334
elapsed = 3
$.easing.easeInQuad(null, elapsed, initialValue, amountOfChange, duration)
//> 400
所以与概要相比:
$.easing.easeInQuad = function (x, t, b, c, d) {...}
我们可以推断:
x t b c d
| | | | |
null elapsed initialValue amountOfChange duration
NB1:一件重要的事情是elapsed(t) 和duration(d) 应该用相同的单位表示,例如:这里对我们来说是“秒”,但可以是“毫秒”管他呢。 initialValue(b) 和amountOfChange(c) 也是如此,总结一下:
x t b c d
| | | | |
null elapsed initialValue amountOfChange duration
^ ^ ^ ^
+----------|----=unit=----|------------+
+----=unit=----+
NB2:就像@DamonJW,我不知道为什么x 在这里。它没有出现在Penner's equations 中,并且在结果中出现not seem to be used:让始终将他设置为null