| ... | ... | @@ -52,11 +52,12 @@ export function FontSizeSliderRow(props: { |
| 52 | 52 | }, [dragging, fraction, progress]); |
| 53 | 53 | |
| 54 | 54 | const commit = useCallback((next: number) => { |
| 55 | | if (next === latest.current.value) { |
| 55 | const current = latest.current; |
| 56 | if (next === current.value) { |
| 56 | 57 | return; |
| 57 | 58 | } |
| 58 | 59 | Haptics.selectionAsync().catch(() => undefined); |
| 59 | | latest.current.onChange(next); |
| 60 | current.onChange(next); |
| 60 | 61 | }, []); |
| 61 | 62 | |
| 62 | 63 | const gesture = useMemo(() => { |
| ... | ... | @@ -90,17 +91,19 @@ export function FontSizeSliderRow(props: { |
| 90 | 91 | dragging.value = true; |
| 91 | 92 | const f = fractionAt(event.x); |
| 92 | 93 | progress.value = f; |
| 93 | | runOnJS(commit)(valueAtFraction(f)); |
| 94 | 94 | }) |
| 95 | | .onFinalize(() => { |
| 95 | .onFinalize((_event, success) => { |
| 96 | 96 | if (!dragging.value) { |
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | dragging.value = false; |
| 100 | | progress.value = withTiming( |
| 101 | | fractionOfValue(valueAtFraction(progress.value)), |
| 102 | | SNAP_ANIMATION, |
| 103 | | ); |
| 100 | if (!success) { |
| 101 | progress.value = withTiming(fractionOfValue(value), SNAP_ANIMATION); |
| 102 | return; |
| 103 | } |
| 104 | const next = valueAtFraction(progress.value); |
| 105 | progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION); |
| 106 | runOnJS(commit)(next); |
| 104 | 107 | }); |
| 105 | 108 | |
| 106 | 109 | const tap = Gesture.Tap() |
| ... | ... | @@ -112,7 +115,7 @@ export function FontSizeSliderRow(props: { |
| 112 | 115 | }); |
| 113 | 116 | |
| 114 | 117 | return Gesture.Race(pan, tap); |
| 115 | | }, [commit, disabled, dragging, max, min, progress, step, trackWidth]); |
| 118 | }, [commit, disabled, dragging, max, min, progress, step, trackWidth, value]); |
| 116 | 119 | |
| 117 | 120 | const fillStyle = useAnimatedStyle(() => ({ |
| 118 | 121 | width: THUMB_SIZE / 2 + progress.value * Math.max(0, trackWidth.value - THUMB_SIZE), |