We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0282de commit 97cd758Copy full SHA for 97cd758
lib/movementtype.function.ts
@@ -1,14 +1,15 @@
1
export const linear = (
2
- amountOfSteps: number,
3
- speedInPixelsPerSecond: number,
+ amountOfSteps: number,
+ speedInPixelsPerSecond: number,
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;
+ const timeSteps = [];
+ // Duration per movement step in nanoseconds
+ let stepDuration = (1 / speedInPixelsPerSecond) * 1_000_000_000;
+ if (stepDuration <= 0) {
+ stepDuration = 0;
+ }
+ for (let idx = 0; idx < amountOfSteps; ++idx) {
+ timeSteps.push(stepDuration);
14
+ return timeSteps;
15
};
0 commit comments