Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
yhattav committed Dec 3, 2024
1 parent 3212639 commit 4e49c0b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/hooks/useSmoothAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { Position, TargetPosition } from '../types';
const SMOOTHING_THRESHOLD = 0.1;

export function useSmoothAnimation(
targetPosition: TargetPosition,
targetPosition: Position,
smoothFactor: number,
setPosition: React.Dispatch<React.SetStateAction<Position>>
): void {
// Memoize the smoothing calculation
const calculateNewPosition = useCallback(
(currentPosition: Position) => {
if (currentPosition.x === null || currentPosition.y === null) {
if (
currentPosition.x === null ||
currentPosition.y === null ||
targetPosition.x === null ||
targetPosition.y === null
) {
return currentPosition;
}

Expand Down

0 comments on commit 4e49c0b

Please sign in to comment.