pull/2678/head
Richard Harris 5 years ago
parent 0ce8dc9d17
commit 0275aab800

@ -22,7 +22,7 @@ function tick_spring(ctx, last_value, current_value, target_value) {
return current_value.map((_, i) =>
tick_spring(ctx, last_value[i], current_value[i], target_value[i]));
} else if (typeof current_value === 'object') {
let next_value = {};
const next_value = {};
for (const k in current_value)
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
return next_value;
@ -35,7 +35,9 @@ export function spring(value, opts = {}) {
const store = writable(value);
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
let last_time, task, current_token;
let last_time;
let task;
let current_token;
let last_value = value;
let target_value = value;
@ -54,7 +56,7 @@ export function spring(value, opts = {}) {
store.set(value = target_value);
return new Promise(f => f()); // fulfil immediately
} else if (opts.soft) {
let rate = opts.soft === true ? .5 : +opts.soft;
const rate = opts.soft === true ? .5 : +opts.soft;
inv_mass_recovery_rate = 1 / (rate * 60);
inv_mass = 0; // infinite mass, unaffected by spring forces
}

Loading…
Cancel
Save