Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/demo/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,17 @@ const finishMovement = () => {

// Calculate the screen's current X offset.
const getOffsetForTime = (t, totalFish) => {
// Normalize the fish movement amount from 0 to 1.
let amount = t / moveTime;

// Apply an S-curve to that amount.
amount = amount - Math.sin(amount*2*Math.PI) / (2*Math.PI);

return (
constants.fishCanvasWidth * totalFish -
constants.canvasWidth / 2 +
constants.fishCanvasWidth / 2 -
Math.round((t * constants.fishCanvasWidth) / moveTime)
Math.round(amount * constants.fishCanvasWidth)
);
};

Expand Down