We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0e620e8 + a80c925 commit 70b0d31Copy full SHA for 70b0d31
src/demo/renderer.js
@@ -162,11 +162,17 @@ const finishMovement = () => {
162
163
// Calculate the screen's current X offset.
164
const getOffsetForTime = (t, totalFish) => {
165
+ // Normalize the fish movement amount from 0 to 1.
166
+ let amount = t / moveTime;
167
+
168
+ // Apply an S-curve to that amount.
169
+ amount = amount - Math.sin(amount*2*Math.PI) / (2*Math.PI);
170
171
return (
172
constants.fishCanvasWidth * totalFish -
173
constants.canvasWidth / 2 +
174
constants.fishCanvasWidth / 2 -
- Math.round((t * constants.fishCanvasWidth) / moveTime)
175
+ Math.round(amount * constants.fishCanvasWidth)
176
);
177
};
178
0 commit comments