File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change 1
1
export const linear = (
2
- amountOfSteps : number ,
3
- speedInPixelsPerSecond : number ,
2
+ amountOfSteps : number ,
3
+ speedInPixelsPerSecond : number ,
4
4
) : number [ ] => {
5
- const timeSteps = [ ] ;
6
- let stepDuration = Math . floor ( ( 1 / speedInPixelsPerSecond ) * 1000 ) ;
7
- if ( stepDuration <= 0 ) {
8
- stepDuration = 1 ;
9
- }
10
- for ( let idx = 0 ; idx < amountOfSteps ; ++ idx ) {
11
- timeSteps . push ( stepDuration ) ;
12
- }
13
- return timeSteps ;
5
+ const timeSteps = [ ] ;
6
+ // Duration per movement step in nanoseconds
7
+ let stepDuration = ( 1 / speedInPixelsPerSecond ) * 1_000_000_000 ;
8
+ if ( stepDuration <= 0 ) {
9
+ stepDuration = 0 ;
10
+ }
11
+ for ( let idx = 0 ; idx < amountOfSteps ; ++ idx ) {
12
+ timeSteps . push ( stepDuration ) ;
13
+ }
14
+ return timeSteps ;
14
15
} ;
You can’t perform that action at this time.
0 commit comments