alantoa / react-native-awesome-slider

🚀 An anwesome <Slider/> that supports various features haptic, lottie, animation, ballon, etc.
MIT License
228 stars 28 forks source link

The thumb doesn't follow when the `progress` value has actually changed #41

Open tcf01 opened 1 year ago

tcf01 commented 1 year ago

Hi guys, I am using react-native-awesome-slider 2.4.0 version but I encounter some strange things. Here is my code & a reference video. What should I modify in the code? Thank u very much!

  1. the thumb doesn't follow while the progress has actually changed
  2. the bubble & the mark seems to have no effect
import {Box} from 'native-base'

const budget = 30 // it is a value from redux store
const progress = useSharedValue(budget);
const minAnimatedValue = useSharedValue(min);
const maxAnimatedValue = useSharedValue(max);

<>
                 <Slider
                        renderBubble={() => <Flex color={"green"}>{budget}</Flex>}
                        renderMark={() => <Text style={{ width: "100%", color: "green" }} >{budget}</Text>}
                        bubble={(s: number) => (Math.floor(Number(s))).toString()}
                        theme={{
                            disableMinTrackTintColor: '#fff',
                            maximumTrackTintColor: '#fff',
                            minimumTrackTintColor: '#999',
                            cacheTrackTintColor: '#333',
                            bubbleBackgroundColor: '#666',
                        }}
                        renderThumb={() => <Box backgroundColor={"white"} w={4} h={4} borderWidth={4} borderRadius={32} borderColor={"#999"} />}
                        minimumValue={minAnimatedValue}
                        maximumValue={maxAnimatedValue}
                        thumbScaleValue={thumbScaleValue}
                        onValueChange={(num) => setBudget(Math.floor(num))}
                        progress={/* { value: budget } */ progress}
                    />
</>

https://github.com/alantoa/react-native-awesome-slider/assets/40299440/2ba0048f-170c-4da9-9e1d-67d947b2ae1f

lamlengend98 commented 10 months ago

My issue is near this. When I swipe the thumb, it doesn't follow my gesture, like it's updated when swipe completing

alantoa commented 9 months ago

Hey, @tcf01, I cannot reproduce this example for my project. Can you create an example project on Expo Snack?

waheedakhtar694 commented 7 months ago

Same here, progress getting increased but the slider position never gets changed.

gimi-anders commented 7 months ago

I had this same issue when using steps so it might be related to that. When I stopped using steps, it works fine.

contactsimonwilson commented 6 months ago

I'm also having the same issue. Will try to diagnose what the issue is.

contactsimonwilson commented 6 months ago

@jacobmolby Adding the following reaction to set the thumbIndex correctly in slide.tsx when the value is changed from the host component fixes the issue

useAnimatedReaction(() => { if (snappingEnabled && !isScrubbing?.value) { const index = Math.round( ((progress.value - minimumValue.value) / (maximumValue.value - minimumValue.value)) * step ); return clamp(index, 0, step); } }, d => { if (typeof d === 'number') thumbIndex.value = d; }, [progress]);

manuelxaguilar commented 3 months ago

I had this same issue when using steps so it might be related to that. When I stopped using steps, it works fine.

Just had this issue and this solved it too

gottfriedaniel commented 1 month ago

I'm also facing the same issue when trying to manually update the thumb progress value. Can also verify that removing the step prop does solve this bug. Is there any estimation regarding this?