Last active
August 29, 2015 14:16
-
-
Save nadar71/0446108516919d9ecea0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local SpringEasing = {} | |
-- EASING | |
local inflectX, inflectY = 0.075, 0.2 | |
local outflectX, outflectY = 1 - inflectX, 1 - inflectY | |
local decay = 12 | |
local function springIn(progress) | |
return progress ^ 4 | |
end | |
local function springOut(progress) | |
return -(2 ^ (-decay * progress)) + 1 | |
end | |
local function springInOut(progress) | |
if progress < inflectX then | |
return inflectY * springIn(progress / inflectX) | |
end | |
return outflectY * springOut((progress-inflectX) * outflectX) + inflectY | |
end | |
local function springEase(t, tMax, start, delta) | |
return start + (delta * springInOut(t / tMax)) | |
end | |
-- PUBLIC | |
function SpringEasing.transition(object, options) | |
if options.time == nil then | |
options.time = 600 | |
end | |
options.transition = springEase | |
return transition.to(object, options) | |
end | |
return SpringEasing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment