gizmosachin / ColorSlider

🎨 Snapchat-style color picker in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trigger an event only after sliding is completed(continuous = false)

akhilcb opened this issue · comments

Thanks for the great library. I would like to have some UISlider type features on this but I am not sure how to approach this.

Currently "valueChanged" event is triggered many times while user is moving the slider thumb. I would like to get an event triggered only when user has completed sliding. UISlider has a property named "continuous" which helps for this kind of situation. However I am not sure how to approach this with ColorSlider.

I would also like to separate the slider thumb from preview view. Right now the slider thumb is acting as preview too. I would like to set a thumb image similar to UISlider which doesn't change its color based on slider position. Instead I would like to connect a separate UIView as Preview View for slider and that UIView would be a fixed static view without any animation along with slider movement. I guess I can implement the thumb image part by implementing "ColorSliderPreviewing" protocol, but just wanted to confirm that. I will also listen to "valueChanged" event for updating preview view background color. Hope that is the right approach.

Hi @akhilcb! Thanks for the feedback.

You can get the event triggered only when the user has completed sliding by using the .touchUpInside and .touchUpOutside, which respectively will only trigger when a selection finishes with a touch inside or outside the slider bounds.

That approach sounds correct. You can implement ColorSliderPreviewing and use the demo app as a guide to show a handle that doesn't animate or even show the selected color. Then, listening for valueChanged will let you implement your own preview that doesn't move.

Thanks for the quick reply. I will check it out.