Skip to content

Instantly share code, notes, and snippets.

@nadar71
Last active August 29, 2015 14:16
Show Gist options
  • Save nadar71/0446108516919d9ecea0 to your computer and use it in GitHub Desktop.
Save nadar71/0446108516919d9ecea0 to your computer and use it in GitHub Desktop.
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