chenglou / tween-functions

Robert Penner's easing functions, slightly modified
Other
185 stars 14 forks source link

c * (t /= d) * t + b ??? #3

Closed ccorcos closed 8 years ago

ccorcos commented 8 years ago

I'm so confused by this line:

https://github.com/chenglou/tween-functions/blob/master/index.js#L11

Why are you using /=?

chenglou commented 8 years ago

The code's literally taken from Robert Penner, who made these for flash a long long time ago.

/= is used because it mutates the value of t, which is used again subsequently. Less confusing way of doing this would be c * (t / d) * (t / d) + b.

Hope that helps!

ccorcos commented 8 years ago

I see. What a terrible way of writing code. lol

chenglou commented 8 years ago

Yeah not too clear. To be fair, that was a decade ago =)

ccorcos commented 8 years ago

Variables with longer names take longer to look up than variables with short names, because of the interpreter’s internal hashing procedure.

http://gilmoreorless.github.io/sydjs-preso-easing/#min-actionscript

Looks like its just a relic of some flash quirks lol

chenglou commented 8 years ago

Ah yes, I remember that! =D