From 23cbc8f4f6f062831ce3de9a35c2c59c5d648105 Mon Sep 17 00:00:00 2001 From: JuchokJuk Date: Thu, 25 Apr 2024 23:54:07 +0300 Subject: [PATCH] fix: Realistic spring behavior at low framerates --- packages/svelte/src/runtime/motion/spring.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/svelte/src/runtime/motion/spring.js b/packages/svelte/src/runtime/motion/spring.js index 68c04923cf8b..dc43edfc5c45 100644 --- a/packages/svelte/src/runtime/motion/spring.js +++ b/packages/svelte/src/runtime/motion/spring.js @@ -103,7 +103,7 @@ export function spring(value, opts = {}) { inv_mass, opts: spring, settled: true, - dt: ((now - last_time) * 60) / 1000 + dt: ((Math.min(now - last_time, 1000 / 24)) * 60) / 1000 // limit delta time to 24fps for realistic spring behavior at low framerates }; const next_value = tick_spring(ctx, last_value, value, target_value); last_time = now;