aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/core/init.lua9
-rw-r--r--data/core/view.lua6
2 files changed, 12 insertions, 3 deletions
diff --git a/data/core/init.lua b/data/core/init.lua
index 0732a3e8..95f535c3 100644
--- a/data/core/init.lua
+++ b/data/core/init.lua
@@ -414,6 +414,7 @@ function core.init()
core.redraw = true
core.visited_files = {}
core.restart_request = false
+ core.frames_lost = 0
core.root_view = RootView()
core.command_view = CommandView()
@@ -869,7 +870,13 @@ function core.run()
else
idle_iterations = 0
local elapsed = system.get_time() - core.frame_start
- system.sleep(math.max(0, frame_duration - elapsed))
+ local remaining = frame_duration - elapsed
+ if remaining > 0 then
+ core.frames_lost = 0
+ system.sleep(remaining)
+ else
+ core.frames_lost = math.ceil(elapsed / frame_duration) - 1
+ end
end
end
end
diff --git a/data/core/view.lua b/data/core/view.lua
index 4d499594..595f2ff0 100644
--- a/data/core/view.lua
+++ b/data/core/view.lua
@@ -24,8 +24,10 @@ function View:move_towards(t, k, dest, rate)
if not config.transitions or math.abs(val - dest) < 0.5 then
t[k] = dest
else
- t[k] = common.lerp(val, dest, rate or 0.5)
- end
+ rate = common.clamp(rate or 0.5, 1e-8, 1 - 1e-8)
+ local alpha = math.log(1 - rate)
+ local dt = (60 / config.fps) * (1 + core.frames_lost)
+ t[k] = common.lerp(val, dest, 1 - math.exp(alpha * dt)) end
if val ~= dest then
core.redraw = true
end