Skip to content

Commit

Permalink
fix: avoid dividing by zero during prerender
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 29, 2020
1 parent ef3df6c commit ca2b9ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hooks/useSpringInterpolations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export function useSpringInterpolations({
// @ts-ignore
[spring.y, spring.minSnap],
(y, minSnap) => {
if (!minSnap) {
return 0
}
const minX = Math.max(minSnap / 2 - 45, 0)
const maxX = Math.min(minSnap / 2 + 45, minSnap)
const minY = 0
Expand All @@ -83,7 +86,7 @@ export function useSpringInterpolations({
const interpolateBackdrop = interpolate(
// @ts-ignore
[spring.y, spring.minSnap],
(y, minSnap) => clamp(y / minSnap, 0, 1)
(y, minSnap) => (minSnap ? clamp(y / minSnap, 0, 1) : 0)
)

return {
Expand Down

0 comments on commit ca2b9ae

Please sign in to comment.