anln_50 #17

Merged
yezian merged 19 commits from anln_50 into main 2024-09-09 13:13:24 +08:00
1 changed files with 8 additions and 25 deletions
Showing only changes of commit d1ad5cfc56 - Show all commits

View File

@ -90,7 +90,7 @@ export default function MySlider({
// };
const _onPanResponderMoveLeft = (e, gestureState) => {
const process =
(gestureState.x0 - 30 - thumbSize / 2 + gestureState.dx) / processWidth;
(gestureState.x0 - thumbSize / 2 + gestureState.dx) / processWidth;
_changeProcess(process, "left");
};
@ -102,7 +102,7 @@ export default function MySlider({
const _onPanResponderMoveRight = (e, gestureState) => {
const process =
(gestureState.x0 + 30 - thumbSize / 2 + gestureState.dx) / processWidth;
(gestureState.x0 - thumbSize / 2 + gestureState.dx) / processWidth;
_changeProcess(process, "right");
};
const _changeProcess = (changeProcess, direction) => {
@ -116,10 +116,10 @@ export default function MySlider({
const newProcess = Math.round(newValue) / (upper_bound - lower_bound);
setStepNum(stepNum + 1);
if (process !== newProcess) {
const currentRightProcess =
(stepValues.indexOf(currentRightValue.current) * step - lower_bound) /
(upper_bound - lower_bound);
if (direction == "left") {
const currentRightProcess =
(stepValues.indexOf(currentRightValue.current) * step - lower_bound) /
(upper_bound - lower_bound);
if (newProcess < currentRightProcess) {
setLeftProcess(newProcess);
setStepNum((old) => old + 1);
@ -264,7 +264,6 @@ export default function MySlider({
width: thumbSize,
height: thumbSize,
borderRadius: 50,
marginTop: -processHeight / 2,
backgroundColor: "#ff75c8",
borderColor: "#ffffff",
borderWidth: 2,
@ -287,6 +286,7 @@ export default function MySlider({
alignItems: "center",
// borderWidth: 2,
}}
{...rightWatcher.current?.panHandlers}
>
<View
style={{
@ -298,7 +298,6 @@ export default function MySlider({
borderColor: "#ffffff",
borderWidth: 2,
}}
{...rightWatcher.current?.panHandlers}
></View>
</View>
@ -317,15 +316,7 @@ export default function MySlider({
color: "#ff75c8",
}}
>
{/* {hasInfinity && leftProcess == 1
? ">" + upper_bound
: stepValues[
Math.round(
(leftProcess * (upper_bound - lower_bound) + lower_bound) /
step
)
]} */}
{leftValue}
{hasInfinity && leftProcess == 1 ? ">" + upper_bound : leftValue}
</Text>
<Text
style={{
@ -343,15 +334,7 @@ export default function MySlider({
color: "#ff75c8",
}}
>
{/* {hasInfinity && Math.floor(rightProcess) == 1
? ">" + upper_bound
: stepValues[
Math.round(
(rightProcess * (upper_bound - lower_bound) + lower_bound) /
step
)
]} */}
{rightValue}
{hasInfinity && rightProcess == 1 ? ">" + upper_bound : rightValue}
</Text>
<Text
style={{