@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/dist/index.js
CHANGED
|
@@ -2536,7 +2536,19 @@ function Slider({
|
|
|
2536
2536
|
const ratio = max > min ? (value - min) / (max - min) : 0;
|
|
2537
2537
|
const usableWidth = Math.max(0, layoutWidth - THUMB_SIZE2);
|
|
2538
2538
|
const thumbLeft = ratio * usableWidth;
|
|
2539
|
-
const
|
|
2539
|
+
const isCenterOrigin = min < 0 && max > 0;
|
|
2540
|
+
let fillLeft;
|
|
2541
|
+
let fillWidth;
|
|
2542
|
+
if (isCenterOrigin) {
|
|
2543
|
+
const centerRatio = (0 - min) / (max - min);
|
|
2544
|
+
const centerX = centerRatio * usableWidth + THUMB_SIZE2 / 2;
|
|
2545
|
+
const thumbCenterX = thumbLeft + THUMB_SIZE2 / 2;
|
|
2546
|
+
fillLeft = Math.min(centerX, thumbCenterX);
|
|
2547
|
+
fillWidth = Math.abs(thumbCenterX - centerX);
|
|
2548
|
+
} else {
|
|
2549
|
+
fillLeft = 0;
|
|
2550
|
+
fillWidth = thumbLeft + THUMB_SIZE2 / 2;
|
|
2551
|
+
}
|
|
2540
2552
|
const handleValueTextSubmit = React14.useCallback(
|
|
2541
2553
|
(text) => {
|
|
2542
2554
|
const raw = Number(text);
|
|
@@ -2579,7 +2591,7 @@ function Slider({
|
|
|
2579
2591
|
...panResponder.panHandlers
|
|
2580
2592
|
},
|
|
2581
2593
|
/* @__PURE__ */ React14.createElement(View, { style: styles.trackRail }),
|
|
2582
|
-
/* @__PURE__ */ React14.createElement(View, { style: [styles.trackFill, { width: fillWidth }] }),
|
|
2594
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.trackFill, { left: fillLeft, width: fillWidth }] }),
|
|
2583
2595
|
/* @__PURE__ */ React14.createElement(View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2584
2596
|
));
|
|
2585
2597
|
}
|