minor tidy up

pull/1937/head
Richard Harris 6 years ago
parent 35aee272d6
commit 84d501b5fb

@ -117,20 +117,18 @@ export function spring(value, opts = {}) {
last_time = window.performance.now(); last_time = window.performance.now();
settled = false; settled = false;
task = loop(() => { task = loop(now=> {
const time = window.performance.now();
({ value, settled } = tick_spring( ({ value, settled } = tick_spring(
velocity, velocity,
value, value,
target_value, target_value,
spring.stiffness, spring.stiffness,
spring.damping, spring.damping,
(time - last_time) * 60 / 1000, (now - last_time) * 60 / 1000,
threshold threshold
)); ));
last_time = time; last_time = now;
if (settled) { if (settled) {
value = target_value; value = target_value;

@ -76,9 +76,8 @@ export function tweened(value, defaults = {}) {
const start = window.performance.now() + delay; const start = window.performance.now() + delay;
let fn; let fn;
task = loop(() => { task = loop(now => {
const time = window.performance.now(); if (now < start) return true;
if (time < start) return true;
if (!started) { if (!started) {
fn = interpolate(value, new_value); fn = interpolate(value, new_value);
@ -91,7 +90,7 @@ export function tweened(value, defaults = {}) {
previous_task = null; previous_task = null;
} }
const elapsed = time - start; const elapsed = now - start;
if (elapsed > duration) { if (elapsed > duration) {
store.set(value = new_value); store.set(value = new_value);

Loading…
Cancel
Save