File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 11import { Readable , writable } from 'svelte/store' ;
2- import { loop , now , Task } from 'svelte/internal' ;
2+ import { loop , Task } from 'svelte/internal' ;
33import { is_date } from './utils' ;
44
55interface TickContext < T > {
@@ -85,7 +85,7 @@ export function spring<T=any>(value?: T, opts: SpringOpts = {}): Spring<T> {
8585
8686 if ( value == null || opts . hard || ( spring . stiffness >= 1 && spring . damping >= 1 ) ) {
8787 cancel_task = true ; // cancel any running animation
88- last_time = now ( ) ;
88+ last_time = null ;
8989 last_value = new_value ;
9090 store . set ( value = target_value ) ;
9191 return Promise . resolve ( ) ;
@@ -96,11 +96,13 @@ export function spring<T=any>(value?: T, opts: SpringOpts = {}): Spring<T> {
9696 }
9797
9898 if ( ! task ) {
99- last_time = now ( ) ;
99+ last_time = null ;
100100 cancel_task = false ;
101101
102102 task = loop ( now => {
103103
104+ if ( last_time === null ) last_time = now ;
105+
104106 if ( cancel_task ) {
105107 cancel_task = false ;
106108 task = null ;
You can’t perform that action at this time.
0 commit comments