Skip to content

Commit

Permalink
make setting tweened with duration=0 instantly update (#4766)
Browse files Browse the repository at this point in the history
  • Loading branch information
tivac authored May 3, 2020
1 parent f111cf6 commit a08a94a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/runtime/motion/tweened.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export function tweened<T>(value?: T, defaults: Options<T> = {}): Tweened<T> {
interpolate = get_interpolator
} = assign(assign({}, defaults), opts);

if (duration === 0) {
store.set(target_value);
return Promise.resolve();
}

const start = now() + delay;
let fn;

Expand Down
7 changes: 7 additions & 0 deletions test/motion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ describe('motion', () => {
size.set(100);
assert.equal(get(size), 100);
});

it('sets immediately when duration is 0', () => {
const size = tweened(0);

size.set(100, { duration : 0 });
assert.equal(get(size), 100);
});
});
});

0 comments on commit a08a94a

Please sign in to comment.