@flighthq/easing 0.2.0 → 0.2.1-next.423.3350e53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/easeSmoothstep.test.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/easing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-next.423.3350e53",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@flighthq/types": "0.2.
|
|
35
|
+
"@flighthq/types": "0.2.1-next.423.3350e53"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.3.0"
|
|
@@ -67,10 +67,27 @@ describe('easeSmoothstepRange', () => {
|
|
|
67
67
|
expect(fn(50)).toBeCloseTo(0.5);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
it('inverts the remap direction when edge0 > edge1', () => {
|
|
71
|
+
const fn = easeSmoothstepRange(20, 10);
|
|
72
|
+
expect(fn(20)).toBe(0);
|
|
73
|
+
expect(fn(10)).toBe(1);
|
|
74
|
+
expect(fn(15)).toBeCloseTo(0.5);
|
|
75
|
+
});
|
|
76
|
+
|
|
70
77
|
it('matches easeSmoothstep when range is [0, 1]', () => {
|
|
71
78
|
const fn = easeSmoothstepRange(0, 1);
|
|
72
79
|
for (const t of [0, 0.25, 0.5, 0.75, 1]) {
|
|
73
80
|
expect(fn(t)).toBeCloseTo(easeSmoothstep(t));
|
|
74
81
|
}
|
|
75
82
|
});
|
|
83
|
+
|
|
84
|
+
it('returns a finite value for edge0 === edge1 (degenerate zero-width range)', () => {
|
|
85
|
+
const fn = easeSmoothstepRange(5, 5);
|
|
86
|
+
// Division by zero: at exactly the edge the numerator is also zero (0/0 → NaN).
|
|
87
|
+
expect(fn(5)).toBeNaN();
|
|
88
|
+
// Above the edge: positive Infinity clamps to 1 → smoothstep(1) = 1.
|
|
89
|
+
expect(fn(6)).toBe(1);
|
|
90
|
+
// Below the edge: negative Infinity clamps to 0 → smoothstep(0) = 0.
|
|
91
|
+
expect(fn(4)).toBe(0);
|
|
92
|
+
});
|
|
76
93
|
});
|