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

How to reset slider progress to 0 or default state #68

Closed AyoCodess closed 2 months ago

AyoCodess commented 3 months ago

via a button click i want to be able to reset the slider, i don't see a way how right now

AyoCodess commented 3 months ago

solution: use a key

abdymm commented 2 months ago

hi @AyoCodess can you pls to elaborate what do you mean by use key? 🙌

AyoCodess commented 2 months ago

hi @AyoCodess can you pls to elaborate what do you mean by use key? 🙌

On the component give it a key, then update that key somewhere else to unmount the component (reset it)

abdymm commented 2 months ago

hi @AyoCodess can you pls to elaborate what do you mean by use key? 🙌

On the component give it a key, then update that key somewhere else to unmount the component (reset it)

oh, thanks for quick reply! if we do that way, isn't that it will have a glitch after you change the key, then first time sliding it ?

https://github.com/alantoa/react-native-awesome-slider/assets/1695466/9f4054cc-0c14-49aa-a4af-5aefa7dc480d

here is the way i toggle the key

<SliderScale
key={isValueEmpty ? 'reset_slider' : 'slider'}
/>

isValueEmpty will be true after you press the Clear Button, or maybe I am wrong on handling the key ? @AyoCodess

AyoCodess commented 2 months ago

hi @AyoCodess can you pls to elaborate what do you mean by use key? 🙌

On the component give it a key, then update that key somewhere else to unmount the component (reset it)

oh, thanks for quick reply! if we do that way, isn't that it will have a glitch after you change the key, then first time sliding it ?

https://github.com/alantoa/react-native-awesome-slider/assets/1695466/9f4054cc-0c14-49aa-a4af-5aefa7dc480d

here is the way i toggle the key


<SliderScale

key={isValueEmpty ? 'reset_slider' : 'slider'}

/>

isValueEmpty will be true after you press the Clear Button, or maybe I am wrong on handling the key ? @AyoCodess

Could you make the default state of the slider start from the left side at 0, and not already filed up?

As when you hit clear, the slider is filled up completely.

abdymm commented 2 months ago

same thing happend, it will like blinking that normal again, is this not happening on your end? @AyoCodess

AyoCodess commented 2 months ago

same thing happend, it will like blinking that normal again, is this not happening on your end? @AyoCodess

I actually navigate away from the page so i don't see it blinking.

So when you reset it to 0 or to whatever starting number you set for your slider it does not animate to it?

This is definitely a missing feature either way.

abdymm commented 2 months ago

I actually navigate away from the page so i don't see it blinking. ah ok thanks why you don't see the glitch,

So when you reset it to 0 or to whatever starting number you set for your slider it does not animate to it?

yess, exactly the same thing that you describe in this thread

ye i guess so, I am about to try to check the lib code, maybe can try to create a PR for that, anyway thanks for your quick replies! 🙌