fix: SlideToConfirm inputRange crash when maxX=0 before layout

This commit is contained in:
Nemo
2026-03-24 13:03:37 +08:00
parent 705e375667
commit 065844b579

View File

@@ -45,8 +45,10 @@ export function SlideToConfirm({ label = 'Slide to confirm', color = '#059669',
).current; ).current;
// Interpolate opacity of the label as handle moves right // Interpolate opacity of the label as handle moves right
// Guard: inputRange must be monotonically non-decreasing (maxX could be 0 before layout)
const safeMax = Math.max(maxX * 0.5, 1);
const labelOpacity = pan.interpolate({ const labelOpacity = pan.interpolate({
inputRange: [0, maxX * 0.5], inputRange: [0, safeMax],
outputRange: [1, 0], outputRange: [1, 0],
extrapolate: 'clamp', extrapolate: 'clamp',
}); });