@newtonedev/components 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -65,7 +65,21 @@ export function Slider({
|
|
|
65
65
|
const ratio = max > min ? (value - min) / (max - min) : 0;
|
|
66
66
|
const usableWidth = Math.max(0, layoutWidth - THUMB_SIZE);
|
|
67
67
|
const thumbLeft = ratio * usableWidth;
|
|
68
|
-
|
|
68
|
+
|
|
69
|
+
// Center-origin fill: when range spans zero, fill extends from center to thumb
|
|
70
|
+
const isCenterOrigin = min < 0 && max > 0;
|
|
71
|
+
let fillLeft: number;
|
|
72
|
+
let fillWidth: number;
|
|
73
|
+
if (isCenterOrigin) {
|
|
74
|
+
const centerRatio = (0 - min) / (max - min);
|
|
75
|
+
const centerX = centerRatio * usableWidth + THUMB_SIZE / 2;
|
|
76
|
+
const thumbCenterX = thumbLeft + THUMB_SIZE / 2;
|
|
77
|
+
fillLeft = Math.min(centerX, thumbCenterX);
|
|
78
|
+
fillWidth = Math.abs(thumbCenterX - centerX);
|
|
79
|
+
} else {
|
|
80
|
+
fillLeft = 0;
|
|
81
|
+
fillWidth = thumbLeft + THUMB_SIZE / 2;
|
|
82
|
+
}
|
|
69
83
|
|
|
70
84
|
const handleValueTextSubmit = React.useCallback(
|
|
71
85
|
(text: string) => {
|
|
@@ -117,7 +131,7 @@ export function Slider({
|
|
|
117
131
|
{...panResponder.panHandlers}
|
|
118
132
|
>
|
|
119
133
|
<View style={styles.trackRail} />
|
|
120
|
-
<View style={[styles.trackFill, { width: fillWidth }]} />
|
|
134
|
+
<View style={[styles.trackFill, { left: fillLeft, width: fillWidth }]} />
|
|
121
135
|
<View style={[styles.thumb, { left: thumbLeft }]} />
|
|
122
136
|
</View>
|
|
123
137
|
</View>
|